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
June 2016
----- 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
17 participants
228 discussions
Start a n
N
ew thread
[zhu] 71658: Partial support for lwIP backlogging. Extra connection contexts are stored in a seemingly valid linked list, but their associated TDI_LISTEN IRPs are overwritten on new TDI_LISTEN call...
by zhu@svn.reactos.org
Author: zhu Date: Tue Jun 21 18:04:55 2016 New Revision: 71658 URL:
http://svn.reactos.org/svn/reactos?rev=71658&view=rev
Log: Partial support for lwIP backlogging. Extra connection contexts are stored in a seemingly valid linked list, but their associated TDI_LISTEN IRPs are overwritten on new TDI_LISTEN calls because they are not yet logged. Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
============================================================================== --- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c [iso-8859-1] (original) +++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c [iso-8859-1] Tue Jun 21 18:04:55 2016 @@ -34,6 +34,8 @@ PDRIVER_CANCEL CancelRoutine ) { + PIO_STACK_LOCATION IrpSp; + PADDRESS_FILE AddressFile; KIRQL OldIrql; DPRINT1("Prepare for cancel\n"); @@ -42,7 +44,11 @@ if (!Irp->Cancel) { + IrpSp = IoGetCurrentIrpStackLocation(Irp); + AddressFile = (PADDRESS_FILE)IrpSp->FileObject->FsContext; + AddressFile->ConnectionContext->PendingIrp = Irp; IoSetCancelRoutine(Irp, CancelRoutine); + IoReleaseCancelSpinLock(OldIrql); return STATUS_SUCCESS; } @@ -82,20 +88,25 @@ switch(MinorFunction) { case TDI_RECEIVE: + DPRINT1("TDI_RECEIVE Cancel\n"); goto TCP_CANCEL; case TDI_RECEIVE_DATAGRAM: DPRINT1("TDI_RECEIVE_DATAGRAM cancelling is handled within TcpIpReceiveDatagram()\n"); goto DGRAM_CANCEL; - break; case TDI_SEND: + DPRINT1("TDI_SEND Cancel\n"); goto TCP_CANCEL; case TDI_SEND_DATAGRAM: + DPRINT1("TDI_SEND_DATAGRAM Cancel\n"); goto DGRAM_CANCEL; case TDI_LISTEN: + DPRINT1("TDI_LISTEN Cancel\n"); goto TCP_CANCEL; case TDI_CONNECT: + DPRINT1("TDI_CONNECT Cancel\n"); goto TCP_CANCEL; case TDI_DISCONNECT: + DPRINT1("TDI_DISCONNECT Cancel\n"); goto TCP_CANCEL; default: DPRINT1("Invalid MinorFunction for cancelling IRP\n"); @@ -105,10 +116,16 @@ TCP_CANCEL: if (AddressFile->ConnectionContext) { - tcp_close(AddressFile->ConnectionContext->lwip_tcp_pcb); - DPRINT1("TCP_CANCEL\n"); - goto FINISH; - } + if (AddressFile->ConnectionContext->lwip_tcp_pcb) + { + tcp_abort(AddressFile->ConnectionContext->lwip_tcp_pcb); + AddressFile->ConnectionContext->PendingIrp = NULL; + AddressFile->ConnectionContext->lwip_tcp_pcb = NULL; + DPRINT1("TCP_CANCEL\n"); + } + } + goto FINISH; + DGRAM_CANCEL: DPRINT1("DGRAM_CANCEL\n"); @@ -252,9 +269,22 @@ DPRINT1("lwIP TCP Accept Callback\n"); - Irp = (PIRP)arg; + AddressFile = (PADDRESS_FILE)arg; + Irp = AddressFile->ConnectionContext->PendingIrp; + if (!Irp) + { + DPRINT1("Callback on canceled IRP\n"); + return ERR_ABRT; + } IrpSp = IoGetCurrentIrpStackLocation(Irp); - AddressFile = (PADDRESS_FILE)IrpSp->FileObject->FsContext; + + if (AddressFile != IrpSp->FileObject->FsContext) + { + DPRINT1("AddressFile Mismatch\n"); + tcp_abort(AddressFile->ConnectionContext->lwip_tcp_pcb); + AddressFile->ConnectionContext->lwip_tcp_pcb = NULL; + return ERR_ABRT; + } IoAcquireCancelSpinLock(&OldIrql); IoSetCancelRoutine(Irp, NULL); @@ -278,6 +308,29 @@ u16_t len ) { + PADDRESS_FILE AddressFile; + PIRP Irp; + KIRQL OldIrql; + + DPRINT1("lwIP TCP Sent Callback\n"); + + AddressFile = (PADDRESS_FILE)arg; + Irp = AddressFile->ConnectionContext->PendingIrp; + if (!Irp) + { + DPRINT1("Callback on canceled IRP\n"); + return ERR_ABRT; + } + + IoAcquireCancelSpinLock(&OldIrql); + IoSetCancelRoutine(Irp, NULL); + Irp->Cancel = FALSE; + IoReleaseCancelSpinLock(OldIrql); + + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = len; + IoCompleteRequest(Irp, IO_NETWORK_INCREMENT); + return ERR_OK; } @@ -293,6 +346,7 @@ { PIRP Irp; PNDIS_BUFFER Buffer; + PADDRESS_FILE AddressFile; PIO_STACK_LOCATION IrpSp; PTDI_REQUEST_KERNEL_RECEIVE ReceiveInfo; KIRQL OldIrql; @@ -305,7 +359,13 @@ DPRINT1("lwIP TCP Receive Callback\n"); - Irp = (PIRP)arg; + AddressFile = (PADDRESS_FILE)arg; + Irp = AddressFile->ConnectionContext->PendingIrp; + if (!Irp) + { + DPRINT1("Callback on canceled IRP\n"); + return ERR_ABRT; + } IoAcquireCancelSpinLock(&OldIrql); IoSetCancelRoutine(Irp, NULL); @@ -316,18 +376,23 @@ IrpSp = IoGetCurrentIrpStackLocation(Irp); ReceiveInfo = (PTDI_REQUEST_KERNEL_RECEIVE)&IrpSp->Parameters; - if (ReceiveInfo->ReceiveLength <= p->len) - { - RtlCopyMemory(Buffer, p->payload, ReceiveInfo->ReceiveLength); - CopiedLength = ReceiveInfo->ReceiveLength; + NdisQueryBuffer(Buffer, &CurrentDestLocation, &RemainingDestBytes); + + DPRINT1("\n PTDI_REQUEST_KERNEL_RECEIVE->ReceiveLength = %d\n NDIS_BUFFER length = %d\n pbuf->tot_len = %d\n", + ReceiveInfo->ReceiveLength, + RemainingDestBytes, + p->tot_len); + + if (RemainingDestBytes <= p->len) + { + RtlCopyMemory(CurrentDestLocation, p->payload, RemainingDestBytes); + CopiedLength = RemainingDestBytes; goto RETURN; } else { CopiedLength = 0; - RemainingDestBytes = ReceiveInfo->ReceiveLength; RemainingSrceBytes = p->len; - CurrentDestLocation = (UCHAR*)Buffer; CurrentSrceLocation = p->payload; while (1) @@ -345,6 +410,7 @@ RemainingSrceBytes = p->next->len; CurrentSrceLocation = p->next->payload; + pbuf_free(p); p = p->next; continue; @@ -365,6 +431,8 @@ } RETURN: + DPRINT1("Receive CopiedLength = %d\n", CopiedLength); + Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = CopiedLength; IoCompleteRequest(Irp, IO_NETWORK_INCREMENT); @@ -425,12 +493,19 @@ struct tcp_pcb *tpcb, err_t err) { + PADDRESS_FILE AddressFile; PIRP Irp; KIRQL OldIrql; DPRINT1("lwIP TCP Connected Callback\n"); - Irp = (PIRP)arg; + AddressFile = (PADDRESS_FILE)arg; + Irp = AddressFile->ConnectionContext->PendingIrp; + if (!Irp) + { + DPRINT1("Callback on canceled IRP\n"); + return ERR_ABRT; + } IoAcquireCancelSpinLock(&OldIrql); IoSetCancelRoutine(Irp, NULL); @@ -452,15 +527,16 @@ ) { PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); - ADDRESS_FILE *AddressFile; + PADDRESS_FILE AddressFile; + PTCP_CONTEXT TcpContext; LIST_ENTRY* ListEntry; KIRQL OldIrql; - ULONG *temp; +// ULONG *temp; USHORT Port = 1; - temp = (ULONG*)Address; +/* temp = (ULONG*)Address; DPRINT1("\n TcpIpCreateAddress Input Dump\n %08x %08x %08x %08x\n", temp[3], temp[2], temp[1], temp[0]); @@ -470,7 +546,7 @@ DPRINT1("\n IrpSp Dump\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", temp[7], temp[6], temp[5], temp[4], temp[3], temp[2], temp[1], temp[0]); - } + }*/ /* See if this port is already taken, and find a free one if needed. */ KeAcquireSpinLock(&AddressListLock, &OldIrql); @@ -524,7 +600,7 @@ ip4_addr_set_u32(&IpAddr, Address->in_addr); while (lwip_netif) { - DPRINT1("Comparing against address %lx\n", lwip_netif->ip_addr.addr); +// DPRINT1("Comparing against address %lx\n", lwip_netif->ip_addr.addr); if (ip_addr_cmp(&IpAddr, &lwip_netif->ip_addr)) { break; @@ -566,15 +642,16 @@ ip_addr_t IpAddr; ip4_addr_set_u32(&IpAddr, AddressFile->Address.in_addr); InsertEntityInstance(CO_TL_ENTITY, &AddressFile->Instance); - AddressFile->ConnectionContext = NULL; -/* tcp_bind(AddressFile->lwip_tcp_pcb, &IpAddr, lwip_ntohs(AddressFile->Address.sin_port)); - DPRINT1("\n Attempt Bind to Address\n Port: %04x\n Address: %08x\n", - AddressFile->Address.sin_port, - IpAddr);*/ - temp = (ULONG*)&AddressFile->Address; - DPRINT1("\n Dump: %08x %08x\n", - temp[1], - temp[0]); + + TcpContext + = ExAllocatePoolWithTag(NonPagedPool, sizeof(TCP_CONTEXT), TAG_ADDRESS_FILE); + InitializeListHead(&TcpContext->ListEntry); + TcpContext->AddressFile = AddressFile; + TcpContext->Protocol = IPPROTO_TCP; + TcpContext->PendingIrp = NULL; + TcpContext->lwip_tcp_pcb = tcp_new(); + AddressFile->ConnectionContext = TcpContext; + AddressFile->ContextCount = 0; break; } case IPPROTO_UDP: @@ -633,11 +710,11 @@ PIO_STACK_LOCATION IrpSp; PTCP_CONTEXT Context; - ULONG *temp; +// ULONG *temp; IrpSp = IoGetCurrentIrpStackLocation(Irp); - temp = (ULONG*)Address; +/* temp = (ULONG*)Address; DPRINT1("\n TcpIpCreateAddress Input Dump\n %08x %08x %08x %08x\n", temp[3], temp[2], temp[1], temp[0]); @@ -649,7 +726,7 @@ temp[7], temp[6], temp[5], temp[4], temp[3], temp[2], temp[1], temp[0]); } - } + }*/ Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Context), TAG_ADDRESS_FILE); if (!Context) @@ -663,12 +740,8 @@ return STATUS_INVALID_PARAMETER; } Context->Protocol = Protocol; - Context->RequestAddress = *Address; - Context->lwip_tcp_pcb = tcp_new(); - if (Context->lwip_tcp_pcb == NULL) - { - return STATUS_NO_MEMORY; - } + RtlCopyMemory(&Context->RequestAddress, Address, sizeof(*Address)); + Context->lwip_tcp_pcb = NULL; IrpSp->FileObject->FsContext = (PVOID)Context; IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONNECTION_FILE; @@ -682,6 +755,11 @@ _Inout_ ADDRESS_FILE* AddressFile ) { + LIST_ENTRY *Entry; + LIST_ENTRY *Temp; + LIST_ENTRY *Head; + PTCP_CONTEXT CurrentContext; + KIRQL OldIrql; /* Lock the global address list */ @@ -700,9 +778,30 @@ udp_remove(AddressFile->lwip_udp_pcb); else if (AddressFile->Protocol == IPPROTO_TCP && AddressFile->ConnectionContext) { + if (AddressFile->ContextCount != 0) + { + Head = &AddressFile->ConnectionContext->ListEntry; + Entry = Head->Flink; + while (Entry != Head) + { + Temp = Entry->Flink; + + CurrentContext = CONTAINING_RECORD(Entry, TCP_CONTEXT, ListEntry); + RemoveEntryList(Entry); + ExFreePoolWithTag(CurrentContext, TAG_ADDRESS_FILE); + AddressFile->ContextCount--; + Entry = Temp; + } + if (AddressFile->ContextCount != 0) + { + DPRINT1("Still contexts remaining after deallocation\n"); + return STATUS_UNSUCCESSFUL; + } + } if (AddressFile->ConnectionContext->lwip_tcp_pcb) { tcp_close(AddressFile->ConnectionContext->lwip_tcp_pcb); + AddressFile->ConnectionContext->lwip_tcp_pcb = NULL; } ExFreePoolWithTag(AddressFile->ConnectionContext, TAG_ADDRESS_FILE); } @@ -840,7 +939,7 @@ (ip_addr_t *)&SocketAddressInRemote->sin_addr.s_addr, SocketAddressInRemote->sin_port, lwip_tcp_Connected_callback); - DPRINT1("lwip error %d\n", lwip_err); +// DPRINT1("lwip error %d\n", lwip_err); switch (lwip_err) { case (ERR_VAL) : @@ -879,9 +978,9 @@ } case (ERR_OK) : { - DPRINT1("lwip ERR_OK\n"); +// DPRINT1("lwip ERR_OK\n"); PrepareIrpForCancel(Irp, CancelRequestRoutine); - tcp_arg(AddressFile->ConnectionContext->lwip_tcp_pcb, Irp); + tcp_arg(AddressFile->ConnectionContext->lwip_tcp_pcb, AddressFile); break; } default : @@ -905,6 +1004,7 @@ PADDRESS_FILE AddressFile; PTDI_REQUEST_KERNEL_ASSOCIATE RequestInfo; PFILE_OBJECT FileObject; + KIRQL OldIrql; err_t lwip_err; NTSTATUS Status; @@ -918,6 +1018,13 @@ goto LEAVE; } Context = IrpSp->FileObject->FsContext; + + if (Context->lwip_tcp_pcb || Context->Protocol != IPPROTO_TCP) + { + DPRINT1("Connection context is not a new TCP context\n"); + Status = STATUS_INVALID_PARAMETER; + goto LEAVE; + } /* Get address file */ RequestInfo = (PTDI_REQUEST_KERNEL_ASSOCIATE)&IrpSp->Parameters; @@ -949,71 +1056,80 @@ return STATUS_INVALID_PARAMETER; } + KeAcquireSpinLock(&AddressFile->RequestLock, &OldIrql); + if (AddressFile->Address.in_addr == 0) { // should really look through address file list for an interface AddressFile->Address.in_addr = 0x0100007f; } - DPRINT1("\n TDI Address\n Port: %04x\n Address: %08x\n", +/* DPRINT1("\n TDI Address\n Port: %04x\n Address: %08x\n", AddressFile->Address.sin_port, - AddressFile->Address.in_addr); - - /* Finally calling into lwip to perform socket bind */ - ip_set_option(Context->lwip_tcp_pcb, SOF_REUSEADDR); - lwip_err = tcp_bind( - Context->lwip_tcp_pcb, - (ip_addr_t *)&AddressFile->Address.in_addr, - AddressFile->Address.sin_port); - ip_set_option(Context->lwip_tcp_pcb, SOF_BROADCAST); - DPRINT1("lwip error %d\n TCP PCB:\n Local Address: %08x\n Local Port: %04x\n Remote Address: %08x\n Remote Port: %04x\n", - lwip_err, - Context->lwip_tcp_pcb->local_ip, - Context->lwip_tcp_pcb->local_port, - Context->lwip_tcp_pcb->remote_ip, - Context->lwip_tcp_pcb->remote_port); - + AddressFile->Address.in_addr);*/ + + Context->AddressFile = AddressFile; + Context->lwip_tcp_pcb = AddressFile->ConnectionContext->lwip_tcp_pcb; + InsertTailList(&AddressFile->ConnectionContext->ListEntry, + &Context->ListEntry); + AddressFile->ContextCount++; + + if (AddressFile->ContextCount <= 1) + { + /* Finally calling into lwip to perform socket bind */ + lwip_err = tcp_bind( + Context->lwip_tcp_pcb, + (ip_addr_t *)&AddressFile->Address.in_addr, + AddressFile->Address.sin_port); + ip_set_option(Context->lwip_tcp_pcb, SOF_BROADCAST); + DPRINT1("lwip error %d\n TCP PCB:\n Local Address: %08x\n Local Port: %04x\n Remote Address: %08x\n Remote Port: %04x\n", + lwip_err, + Context->lwip_tcp_pcb->local_ip, + Context->lwip_tcp_pcb->local_port, + Context->lwip_tcp_pcb->remote_ip, + Context->lwip_tcp_pcb->remote_port); + + if (lwip_err != ERR_OK) + { + switch (lwip_err) + { + case (ERR_BUF) : + { + DPRINT1("lwIP ERR_BUFF\n"); + Status = STATUS_NO_MEMORY; + goto LEAVE; + } + case (ERR_VAL) : + { + DPRINT1("lwIP ERR_VAL\n"); + Status = STATUS_INVALID_PARAMETER; + goto LEAVE; + } + case (ERR_USE) : + { + DPRINT1("lwIP ERR_USE\n"); + Status = STATUS_ADDRESS_ALREADY_EXISTS; + goto LEAVE; + } + case (ERR_OK) : + { + DPRINT1("lwIP ERR_OK\n"); + break; + } + default : + { + DPRINT1("lwIP unexpected error\n"); + Status = STATUS_NOT_IMPLEMENTED; + goto LEAVE; + } + } + } + } + + KeReleaseSpinLock(&AddressFile->RequestLock, OldIrql); + IrpSp->FileObject->FsContext = AddressFile; IrpSp->FileObject->FsContext2 = (PVOID)TDI_TRANSPORT_ADDRESS_FILE; - - if (lwip_err != ERR_OK) - { - switch (lwip_err) - { - case (ERR_BUF) : - { - DPRINT1("lwIP ERR_BUFF\n"); - Status = STATUS_NO_MEMORY; - goto LEAVE; - } - case (ERR_VAL) : - { - DPRINT1("lwIP ERR_VAL\n"); - Status = STATUS_INVALID_PARAMETER; - goto LEAVE; - } - case (ERR_USE) : - { - DPRINT1("lwIP ERR_USE\n"); - Status = STATUS_ADDRESS_ALREADY_EXISTS; - goto LEAVE; - } - case (ERR_OK) : - { - DPRINT1("lwIP ERR_OK\n"); - break; - } - default : - { - DPRINT1("lwIP unexpected error\n"); - Status = STATUS_NOT_IMPLEMENTED; - goto LEAVE; - } - } - } - - Context->AddressFile = AddressFile; - AddressFile->ConnectionContext = Context; Status = STATUS_SUCCESS; LEAVE: @@ -1028,7 +1144,11 @@ { PIO_STACK_LOCATION IrpSp; PTCP_CONTEXT Context; + PTCP_CONTEXT CurrentContext; PADDRESS_FILE AddressFile; + KIRQL OldIrql; + LIST_ENTRY *Head; + LIST_ENTRY *Entry; IrpSp = IoGetCurrentIrpStackLocation(Irp); if ((ULONG)IrpSp->FileObject->FsContext2 != TDI_TRANSPORT_ADDRESS_FILE) @@ -1055,6 +1175,29 @@ DPRINT1("Address File and Context have mismatching protocols\n"); return STATUS_INVALID_ADDRESS; } + + KeAcquireSpinLock(&AddressFile->RequestLock, &OldIrql); + + Head = &AddressFile->ConnectionContext->ListEntry; + Entry = Head->Flink; + if (Entry == Head) + { + DPRINT1("Disassociating from empty context list\n"); + KeReleaseSpinLock(&AddressFile->RequestLock, OldIrql); + return STATUS_INVALID_ADDRESS; + } + if (AddressFile->ContextCount < 1) + { + DPRINT1("Invalid ContextCount\n"); + KeReleaseSpinLock(&AddressFile->RequestLock, OldIrql); + return STATUS_INVALID_ADDRESS; + } + CurrentContext = CONTAINING_RECORD(Entry, TCP_CONTEXT, ListEntry); + RemoveEntryList(Entry); + ExFreePoolWithTag(CurrentContext, TAG_ADDRESS_FILE); + AddressFile->ContextCount--; + + KeReleaseSpinLock(&AddressFile->RequestLock, OldIrql); return STATUS_SUCCESS; } @@ -1088,26 +1231,27 @@ return STATUS_INVALID_ADDRESS; } - /* Call down into lwip to initiate a listen */ - lpcb = tcp_listen(ConnectionContext->lwip_tcp_pcb); - DPRINT1("lwip tcp_listen returned\n"); - if (lpcb == NULL) - { - /* tcp_listen returning NULL can mean - either INVALID_ADDRESS or NO_MEMORY - if SO_REUSE is enabled in lwip options */ - DPRINT1("lwip tcp_listen error\n"); - return STATUS_INVALID_ADDRESS; - } - else - { - ConnectionContext->lwip_tcp_pcb = lpcb; - } - PrepareIrpForCancel(Irp, CancelRequestRoutine); - - tcp_accept(ConnectionContext->lwip_tcp_pcb, lwip_tcp_accept_callback); - tcp_arg(ConnectionContext->lwip_tcp_pcb, Irp); + if (AddressFile->ContextCount <= 1) + { + /* Call down into lwip to initiate a listen */ + lpcb = tcp_listen(ConnectionContext->lwip_tcp_pcb); + DPRINT1("lwip tcp_listen returned\n"); + if (lpcb == NULL) + { + /* tcp_listen returning NULL can mean + either INVALID_ADDRESS or NO_MEMORY + if SO_REUSE is enabled in lwip options */ + DPRINT1("lwip tcp_listen error\n"); + return STATUS_INVALID_ADDRESS; + } + else + { + ConnectionContext->lwip_tcp_pcb = lpcb; + } + tcp_accept(ConnectionContext->lwip_tcp_pcb, lwip_tcp_accept_callback); + tcp_arg(ConnectionContext->lwip_tcp_pcb, AddressFile); + } return STATUS_PENDING; } @@ -1120,7 +1264,8 @@ PTDI_REQUEST_KERNEL_SEND Request; PADDRESS_FILE AddressFile; PTCP_CONTEXT Context; - PNDIS_BUFFER Buffer; + PVOID Buffer; + UINT Len; err_t lwip_err; @@ -1146,7 +1291,11 @@ DPRINT1("TcpIpSendEmpty\n"); return STATUS_INVALID_PARAMETER; } - Buffer = (PNDIS_BUFFER)Irp->MdlAddress; + NdisQueryBuffer(Irp->MdlAddress, &Buffer, &Len); + + DPRINT1("\n PTDI_REQUEST_KERNEL_SEND->SendLength = %d\n NDIS_BUFFER Length = %d\n", + Request->SendLength, + Len); if (!Context->lwip_tcp_pcb) { @@ -1174,7 +1323,8 @@ return STATUS_NOT_IMPLEMENTED; } - tcp_arg(Context->lwip_tcp_pcb, Irp); + PrepareIrpForCancel(Irp, CancelRequestRoutine); + tcp_arg(Context->lwip_tcp_pcb, AddressFile); tcp_sent(Context->lwip_tcp_pcb, lwip_tcp_sent_callback); return STATUS_PENDING; @@ -1188,6 +1338,8 @@ PADDRESS_FILE AddressFile; PTCP_CONTEXT Context; + PTDI_REQUEST_KERNEL_RECEIVE RequestInfo; + IrpSp = IoGetCurrentIrpStackLocation(Irp); if (IrpSp->FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) @@ -1210,9 +1362,12 @@ return STATUS_INVALID_ADDRESS; } + RequestInfo = (PTDI_REQUEST_KERNEL_RECEIVE)&IrpSp->Parameters; + DPRINT1("\n Request Length = %d\n", RequestInfo->ReceiveLength); + PrepareIrpForCancel(Irp, CancelRequestRoutine); tcp_recv(Context->lwip_tcp_pcb, lwip_tcp_receive_callback); - tcp_arg(Context->lwip_tcp_pcb, Irp); + tcp_arg(Context->lwip_tcp_pcb, AddressFile); return STATUS_PENDING; } Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
============================================================================== --- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h [iso-8859-1] (original) +++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h [iso-8859-1] Tue Jun 21 18:04:55 2016 @@ -4,6 +4,7 @@ typedef struct _ADDRESS_FILE { LIST_ENTRY ListEntry; LONG RefCount; + LONG ContextCount; IPPROTO Protocol; TDI_ADDRESS_IP Address; TCPIP_INSTANCE Instance; @@ -18,13 +19,11 @@ } ADDRESS_FILE, *PADDRESS_FILE; typedef struct _TCP_CONTEXT { - ADDRESS_FILE *AddressFile; LIST_ENTRY ListEntry; + PADDRESS_FILE AddressFile; IPPROTO Protocol; TDI_ADDRESS_IP RequestAddress; - LONG RefCount; - KSPIN_LOCK Lock; - KIRQL OldIrql; + PIRP PendingIrp; struct tcp_pcb* lwip_tcp_pcb; } TCP_CONTEXT, *PTCP_CONTEXT; Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
============================================================================== --- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c [iso-8859-1] (original) +++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c [iso-8859-1] Tue Jun 21 18:04:55 2016 @@ -212,7 +212,7 @@ IPPROTO Protocol; // ADDRESS_FILE *AddressFile; - ULONG *temp; +// ULONG *temp; PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); @@ -265,23 +265,18 @@ } /* All good. */ - temp = (ULONG*)Address; +/* temp = (ULONG*)Address; DPRINT1("\nPTA_IP_ADDRESS dump before\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", temp[7], temp[6], temp[5], temp[4], - temp[3], temp[2], temp[1], temp[0]); + temp[3], temp[2], temp[1], temp[0]);*/ Status = TcpIpCreateAddress(Irp, &Address->Address[0].Address[0], Protocol); if (Status != STATUS_SUCCESS) { goto Quickie; } - -/* AddressFile = IrpSp->FileObject->FsContext; - tcp_bind(AddressFile->lwip_tcp_pcb, - (ip_addr_t*)&AddressFile->Address.in_addr, - AddressFile->Address.sin_port);*/ - DPRINT1("\nPTA_IP_ADDRESS dump after\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", +/* DPRINT1("\nPTA_IP_ADDRESS dump after\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", temp[7], temp[6], temp[5], temp[4], - temp[3], temp[2], temp[1], temp[0]); + temp[3], temp[2], temp[1], temp[0]);*/ break; } @@ -307,19 +302,19 @@ goto Quickie; } - temp = (ULONG*)Protocol; +/* temp = (ULONG*)Protocol; DPRINT1("\n Protocol: %08x\n", temp); - temp = (ULONG*)Address; + temp = (ULONG*)Address;*/ /* All good. */ - DPRINT1("\n PTA_IP_ADDRESS dump before\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", +/* DPRINT1("\n PTA_IP_ADDRESS dump before\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", temp[7], temp[6], temp[5], temp[4], - temp[3], temp[2], temp[1], temp[0]); + temp[3], temp[2], temp[1], temp[0]);*/ Status = TcpIpCreateContext(Irp, &Address->Address[0].Address[0], Protocol); - DPRINT1("\n PTA_IP_ADDRESS dump after\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", +/* DPRINT1("\n PTA_IP_ADDRESS dump after\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", temp[7], temp[6], temp[5], temp[4], - temp[3], temp[2], temp[1], temp[0]); + temp[3], temp[2], temp[1], temp[0]);*/ break; } @@ -386,7 +381,7 @@ IoCompleteRequest(Irp, IO_NETWORK_INCREMENT); - return Irp->IoStatus.Status; + return Status; } static
8 years, 7 months
1
0
0
0
[spetreolle] 71657: Add AHK_Tests to ignore list.
by spetreolle@svn.reactos.org
Author: spetreolle Date: Tue Jun 21 14:58:04 2016 New Revision: 71657 URL:
http://svn.reactos.org/svn/reactos?rev=71657&view=rev
Log: Add AHK_Tests to ignore list. Modified: trunk/reactos/modules/ (props changed) Propchange: trunk/reactos/modules/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Tue Jun 21 14:58:04 2016 @@ -12,3 +12,4 @@ bootcd_extras livecd_extras hybridcd_extras +AHK_Tests
8 years, 7 months
1
0
0
0
[gedmurphy] 71656: Let's see if reverting the doxyfile makes doxygen useful again (or just breaks it)
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Tue Jun 21 09:02:06 2016 New Revision: 71656 URL:
http://svn.reactos.org/svn/reactos?rev=71656&view=rev
Log: Let's see if reverting the doxyfile makes doxygen useful again (or just breaks it) Modified: trunk/reactos/Doxyfile [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/Doxyfile URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/Doxyfile?rev=71656&r1=7165…
8 years, 7 months
1
0
0
0
[apriyadarshi] 71655: Please look at notes.txt for implementation and progress status.
by apriyadarshi@svn.reactos.org
Author: apriyadarshi Date: Mon Jun 20 11:49:22 2016 New Revision: 71655 URL:
http://svn.reactos.org/svn/reactos?rev=71655&view=rev
Log: Please look at notes.txt for implementation and progress status. Added: branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt (with props) Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h Added: branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt (added) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt [iso-8859-1] Mon Jun 20 11:49:22 2016 @@ -0,0 +1,154 @@ +AhciPortInitialize + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +AhciAllocateResourceForAdapter + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +AhciHwInitialize + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +AhciInterruptHandler + Flags + IMPLEMENTED + TESTED + Comment + Fatal Error not supported + Error Recovery not supported + +AhciHwInterrupt + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +AhciHwStartIo + Flags + IMPLEMENTED + TESTED + Comment + Adapter based IO request not supported + Need to implement more srb functions + +AhciHwResetBus + Flags + NOT_IMPLEMENTED + Comment + Adapter master bus reset not implemented + +AhciHwFindAdapter + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +DriverEntry + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +AhciATA_CFIS + Flags + NOT_IMPLEMENTED + Comment + Need to configure command table according to Srb function + +AhciATAPI_CFIS + Flags + NOT_IMPLEMENTED + Comment + Need to configure command table according to Srb function + +AhciBuild_PRDT + Flags + NOT_IMPLEMENTED + Comment + Need to configure command table according to Srb function + +AhciProcessSrb + Flags + IMPLEMENTED + Comment + Only ATA/ATAPI type CFIS supported + Also I am not sure about FIS alignment in SrbExtension. + +AhciActivatePort + Flags + NOT_IMPLEMENTED + Comment + NONE + +AhciProcessIO + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +DeviceInquiryRequest + Flags + IMPLEMENTED + TESTED + Comment + EVPD is not sending Data buffer for IDENTIFY command. + Need to implement VPD + +AhciAdapterReset + Flags + NOT_IMPLEMENTED + Comment + NONE + +AhciZeroMemory + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +IsPortValid + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +AddQueue + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE + +RemoveQueue + Flags + IMPLEMENTED + FULLY_SUPPORTED + TESTED + Comment + NONE Propchange: branches/GSoC_2016/AHCI/drivers/storage/storahci/Notes.txt ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] Mon Jun 20 11:49:22 2016 @@ -66,13 +66,13 @@ // ï· PxFB and PxFBU (if CAP.S64A is set to â1â) // Note: Assuming 32bit support only StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->CLB, commandListPhysical.LowPart); - if ((adapterExtension->CAP & AHCI_Global_HBA_CAP_S64A) != 0) + if (IsAdapterCAPS64(adapterExtension->CAP)) { StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->CLBU, commandListPhysical.HighPart); } StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->FB, receivedFISPhysical.LowPart); - if ((adapterExtension->CAP & AHCI_Global_HBA_CAP_S64A) != 0) + if (IsAdapterCAPS64(adapterExtension->CAP)) { StorPortWriteRegisterUlong(adapterExtension, &PortExtension->Port->FBU, receivedFISPhysical.HighPart); } @@ -355,7 +355,7 @@ /** * @name AhciHwStartIo - * @implemented + * @not_implemented * * The Storport driver calls the HwStorStartIo routine one time for each incoming I/O request. * @@ -627,7 +627,7 @@ // 3.1.2 -- AE bit is read-write only if CAP.SAM is '0' ghc = StorPortReadRegisterUlong(adapterExtension, &abar->GHC); // AE := Highest Significant bit of GHC - if ((ghc & AHCI_Global_HBA_CONTROL_AE) != 0)//Hmm, controller was already in power state + if ((ghc & AHCI_Global_HBA_CONTROL_AE) != 0)// Hmm, controller was already in power state { // reset controller to have it in known state DebugPrint("\tAE Already set, Reset()\n"); @@ -672,7 +672,7 @@ for (index = 0; index < adapterExtension->PortCount; index++) { - if ((adapterExtension->PortImplemented & (0x1<<index)) != 0) + if ((adapterExtension->PortImplemented & (0x1 << index)) != 0) AhciPortInitialize(&adapterExtension->PortExtension[index]); } @@ -740,25 +740,178 @@ }// -- DriverEntry(); /** - * @name AhciProcessSrb + * @name AhciATA_CFIS * @not_implemented * - * Prepare Srb for IO processing + * create ATA CFIS from Srb * * @param PortExtension * @param Srb + * + */ +VOID +AhciATA_CFIS ( + __in PAHCI_PORT_EXTENSION PortExtension, + __in PAHCI_SRB_EXTENSION SrbExtension + ) +{ + DebugPrint("AhciATA_CFIS()\n"); + +}// -- AhciATA_CFIS(); + +/** + * @name AhciATAPI_CFIS + * @not_implemented + * + * create ATAPI CFIS from Srb + * + * @param PortExtension + * @param Srb + * + */ +VOID +AhciATAPI_CFIS ( + __in PAHCI_PORT_EXTENSION PortExtension, + __in PAHCI_SRB_EXTENSION SrbExtension + ) +{ + DebugPrint("AhciATAPI_CFIS()\n"); + +}// -- AhciATAPI_CFIS(); + +/** + * @name AhciBuild_PRDT + * @not_implemented + * + * Build PRDT for data transfer + * + * @param PortExtension + * @param Srb + * + * @return + * Return number of entries in PRDT. + */ +ULONG +AhciBuild_PRDT ( + __in PAHCI_PORT_EXTENSION PortExtension, + __in PAHCI_SRB_EXTENSION SrbExtension + ) +{ + DebugPrint("AhciBuild_PRDT()\n"); + + return -1; +}// -- AhciBuild_PRDT(); + +/** + * @name AhciProcessSrb + * @implemented + * + * Prepare Srb for IO processing + * + * @param PortExtension + * @param Srb + * @param SlotIndex * */ VOID AhciProcessSrb ( __in PAHCI_PORT_EXTENSION PortExtension, - __in PSCSI_REQUEST_BLOCK Srb - ) -{ + __in PSCSI_REQUEST_BLOCK Srb, + __in ULONG SlotIndex + ) +{ + ULONG prdtlen, sig, length; + PAHCI_SRB_EXTENSION SrbExtension; + PAHCI_COMMAND_HEADER CommandHeader; + PAHCI_ADAPTER_EXTENSION AdapterExtension; + STOR_PHYSICAL_ADDRESS CommandTablePhysicalAddress; + DebugPrint("AhciProcessSrb()\n"); NT_ASSERT(Srb->PathId == PortExtension->PortNumber); + SrbExtension = Srb->SrbExtension; + AdapterExtension = PortExtension->AdapterExtension; + + NT_ASSERT(SrbExtension != NULL); + NT_ASSERT(SrbExtension->AtaFunction != 0); + + if ((SrbExtension->AtaFunction == ATA_FUNCTION_ATA_IDENTIFY) && + (SrbExtension->Task.CommandReg == IDE_COMMAND_NOT_VALID)) + { + // Here we are safe to check SIG register + sig = StorPortReadRegisterUlong(AdapterExtension, &PortExtension->Port->SIG); + if (sig == 0x101) + { + SrbExtension->Task.CommandReg = IDE_COMMAND_IDENTIFY; + } + else + { + SrbExtension->Task.CommandReg = IDE_COMMAND_ATAPI_IDENTIFY; + } + } + + NT_ASSERT(SlotIndex < AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP)); + SrbExtension->SlotIndex = SlotIndex; + + // program the CFIS in the CommandTable + CommandHeader = &PortExtension->CommandList[SlotIndex]; + + if (IsAtaCommand(SrbExtension->AtaFunction)) + { + AhciATA_CFIS(PortExtension, SrbExtension); + } + else if (IsAtapiCommand(SrbExtension->AtaFunction)) + { + AhciATAPI_CFIS(PortExtension, SrbExtension); + } + + prdtlen = 0; + if (IsDataTransferNeeded(SrbExtension)) + { + prdtlen = AhciBuild_PRDT(PortExtension, SrbExtension); + NT_ASSERT(prdtlen != -1); + } + + // Program the command header + CommandHeader->DI.PRDTL = prdtlen; // number of entries in PRD table + CommandHeader->DI.CFL = 5; + CommandHeader->DI.W = (SrbExtension->Flags & ATA_FLAGS_DATA_OUT) ? 1 : 0; + CommandHeader->DI.P = 0; // ATA Specifications says so + CommandHeader->DI.PMP = 0; // Port Multiplier + + // Reset -- Manual Configuation + CommandHeader->DI.R = 0; + CommandHeader->DI.B = 0; + CommandHeader->DI.C = 0; + + CommandHeader->PRDBC = 0; + + CommandHeader->Reserved[0] = 0; + CommandHeader->Reserved[1] = 0; + CommandHeader->Reserved[2] = 0; + CommandHeader->Reserved[3] = 0; + + // set CommandHeader CTBA + // I am really not sure if SrbExtension is 128 byte aligned or not + // Command FIS will not work if it is not so. + CommandTablePhysicalAddress = StorPortGetPhysicalAddress(AdapterExtension, + NULL, + SrbExtension, + &length); + + // command table alignment + NT_ASSERT((CommandTablePhysicalAddress.LowPart % 128) == 0); + + CommandHeader->CTBA0 = CommandTablePhysicalAddress.LowPart; + + if (IsAdapterCAPS64(AdapterExtension->CAP)) + { + CommandHeader->CTBA_U0 = CommandTablePhysicalAddress.HighPart; + } + + // mark this slot + PortExtension->OccupiedSlots |= SlotIndex; return; }// -- AhciProcessSrb(); @@ -803,7 +956,7 @@ STOR_LOCK_HANDLE lockhandle; PSCSI_REQUEST_BLOCK tmpSrb; PAHCI_PORT_EXTENSION PortExtension; - ULONG commandSlotMask, occupiedSlots, slotIndex; + ULONG commandSlotMask, occupiedSlots, slotIndex, NCS; DebugPrint("AhciProcessIO()\n"); DebugPrint("\tPathId: %d\n", PathId); @@ -824,13 +977,14 @@ StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle); occupiedSlots = PortExtension->OccupiedSlots; // Busy command slots for given port - commandSlotMask = (1 << AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP)) - 1; // available slots mask + NCS = AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP); + commandSlotMask = (1 << NCS) - 1; // available slots mask commandSlotMask = (commandSlotMask & ~occupiedSlots); if(commandSlotMask != 0) { // iterate over HBA port slots - for (slotIndex = 0; slotIndex <= AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP); slotIndex++) + for (slotIndex = 0; slotIndex < NCS; slotIndex++) { // find first free slot if ((commandSlotMask & (1 << slotIndex)) != 0) @@ -839,7 +993,7 @@ if (tmpSrb != NULL) { NT_ASSERT(Srb->PathId == PathId); - AhciProcessSrb(PortExtension, tmpSrb); + AhciProcessSrb(PortExtension, tmpSrb, slotIndex); } else { @@ -887,14 +1041,21 @@ { PVOID DataBuffer; ULONG DataBufferLength; + PAHCI_SRB_EXTENSION SrbExtension; DebugPrint("DeviceInquiryRequest()\n"); + + SrbExtension = Srb->SrbExtension; // 3.6.1 // If the EVPD bit is set to zero, the device server shall return the standard INQUIRY data if (Cdb->CDB6INQUIRY3.EnableVitalProductData == 0) { DebugPrint("\tEVPD Inquired\n"); + NT_ASSERT(SrbExtension != NULL); + + SrbExtension->AtaFunction = ATA_FUNCTION_ATA_IDENTIFY; + SrbExtension->Task.CommandReg = IDE_COMMAND_NOT_VALID; } else { Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] Mon Jun 20 11:49:22 2016 @@ -6,6 +6,7 @@ */ #include <ntddk.h> +#include <ata.h> #include <storport.h> #define DEBUG 1 @@ -20,7 +21,22 @@ #define AHCI_Global_HBA_CONTROL_MRSM (1 << 2) #define AHCI_Global_HBA_CONTROL_AE (1 << 31) #define AHCI_Global_HBA_CAP_S64A (1 << 31) -#define AHCI_Global_Port_CMD_IDLE ((1 << 0) | (1 << 4) | (1 << 14) | (1 << 15)) // PxCMD.ST, PxCMD.CR, PxCMD.FRE and PxCMD.FR + +// ATA Functions +#define ATA_FUNCTION_ATA_COMMAND 0x100 +#define ATA_FUNCTION_ATA_IDENTIFY 0x101 + +// ATAPI Functions +#define ATA_FUNCTION_ATAPI_COMMAND 0x200 + +// ATA Flags +#define ATA_FLAGS_DATA_IN (1 << 1) +#define ATA_FLAGS_DATA_OUT (1 << 2) + +#define IsAtaCommand(AtaFunction) (AtaFunction & ATA_FUNCTION_ATA_COMMAND) +#define IsAtapiCommand(AtaFunction) (AtaFunction & ATA_FUNCTION_ATAPI_COMMAND) +#define IsDataTransferNeeded(SrbExtension) (SrbExtension->Flags & (ATA_FLAGS_DATA_IN | ATA_FLAGS_DATA_OUT)) +#define IsAdapterCAPS64(CAP) (CAP & AHCI_Global_HBA_CAP_S64A) // 3.1.1 NCS = CAP[12:08] -> Align #define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8) @@ -165,10 +181,31 @@ // --------------------------- // ////////////////////////////////////////////////////////////// +typedef union _AHCI_COMMAND_HEADER_DESCRIPTION +{ + struct + { + ULONG CFL :5; // Command FIS Length + ULONG A :1; // IsATAPI + ULONG W :1; // Write + ULONG P :1; // Prefetchable + + ULONG R :1; // Reset + ULONG B :1; // BIST + ULONG C :1; //Clear Busy upon R_OK + ULONG DW0_Reserved :1; + ULONG PMP :4; //Port Multiplier Port + + ULONG PRDTL :16; //Physical Region Descriptor Table Length + }; + + ULONG Status; +} AHCI_COMMAND_HEADER_DESCRIPTION; + // 4.2.2 Command Header typedef struct _AHCI_COMMAND_HEADER { - ULONG HEADER_DESCRIPTION; // DW 0 + AHCI_COMMAND_HEADER_DESCRIPTION DI; // DW 0 ULONG PRDBC; // DW 1 ULONG CTBA0; // DW 2 ULONG CTBA_U0; // DW 3 @@ -265,6 +302,7 @@ ULONG CAP; ULONG CAP2; ULONG LastInterruptPort; + ULONG CurrentCommandSlot; PVOID NonCachedExtension;// holds virtual address to noncached buffer allocated for Port Extension @@ -280,10 +318,20 @@ AHCI_PORT_EXTENSION PortExtension[MAXIMUM_AHCI_PORT_COUNT]; } AHCI_ADAPTER_EXTENSION, *PAHCI_ADAPTER_EXTENSION; +typedef struct _ATA_REGISTER +{ + UCHAR CommandReg; + ULONG Reserved; +} ATA_REGISTER; + typedef struct _AHCI_SRB_EXTENSION { + ULONG AtaFunction; + ULONG Flags; + ATA_REGISTER Task; + ULONG SlotIndex; ULONG Reserved[4]; -} AHCI_SRB_EXTENSION; +} AHCI_SRB_EXTENSION, *PAHCI_SRB_EXTENSION; ////////////////////////////////////////////////////////////// // Declarations //
8 years, 7 months
1
0
0
0
[hbelusca] 71654: [i8042prt]: Add yet another Dell Latitude D620 hack to make its trackpad work. CORE-11431 #resolve CORE-6901
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Jun 19 13:13:01 2016 New Revision: 71654 URL:
http://svn.reactos.org/svn/reactos?rev=71654&view=rev
Log: [i8042prt]: Add yet another Dell Latitude D620 hack to make its trackpad work. CORE-11431 #resolve CORE-6901 Modified: trunk/reactos/drivers/input/i8042prt/hwhacks.c Modified: trunk/reactos/drivers/input/i8042prt/hwhacks.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/i8042prt/hwh…
============================================================================== --- trunk/reactos/drivers/input/i8042prt/hwhacks.c [iso-8859-1] (original) +++ trunk/reactos/drivers/input/i8042prt/hwhacks.c [iso-8859-1] Sun Jun 19 13:13:01 2016 @@ -63,6 +63,7 @@ { {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D530 "}}, FL_INITHACK }, { {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D531 "}}, FL_INITHACK }, { {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D600 "}}, FL_INITHACK }, + { {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D620 "}}, FL_INITHACK }, { {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude D630 "}}, FL_INITHACK }, { {{SYS_VENDOR, "Dell Inc."}, {SYS_PRODUCT, "Latitude E4300 "}}, FL_INITHACK },
8 years, 7 months
1
0
0
0
[ekohl] 71653: [SC] Add EnumDepend command.
by ekohl@svn.reactos.org
Author: ekohl Date: Sat Jun 18 11:18:53 2016 New Revision: 71653 URL:
http://svn.reactos.org/svn/reactos?rev=71653&view=rev
Log: [SC] Add EnumDepend command. Added: trunk/reactos/base/applications/sc/depend.c (with props) Modified: trunk/reactos/base/applications/sc/CMakeLists.txt trunk/reactos/base/applications/sc/print.c trunk/reactos/base/applications/sc/sc.c trunk/reactos/base/applications/sc/sc.h trunk/reactos/base/applications/sc/usage.c Modified: trunk/reactos/base/applications/sc/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/CMake…
============================================================================== --- trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] Sat Jun 18 11:18:53 2016 @@ -6,6 +6,7 @@ control.c create.c delete.c + depend.c description.c failure.c misc.c Added: trunk/reactos/base/applications/sc/depend.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/depen…
============================================================================== --- trunk/reactos/base/applications/sc/depend.c (added) +++ trunk/reactos/base/applications/sc/depend.c [iso-8859-1] Sat Jun 18 11:18:53 2016 @@ -0,0 +1,100 @@ +/* + * PROJECT: ReactOS Services + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/applications/sc/depend.c + * PURPOSE: + * COPYRIGHT: Copyright 2016 Eric Kohl + * + */ + +#include "sc.h" + +BOOL EnumDepend(LPCTSTR ServiceName) +{ + SC_HANDLE hManager = NULL; + SC_HANDLE hService = NULL; + BOOL bResult = TRUE; + DWORD BufferSize = 0; + DWORD EntriesRead = 0; + LPENUM_SERVICE_STATUS pBuffer = NULL; + DWORD i; + + hManager = OpenSCManager(NULL, + NULL, + SC_MANAGER_CONNECT); + if (hManager == NULL) + { + _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + + hService = OpenService(hManager, ServiceName, SERVICE_ENUMERATE_DEPENDENTS); + if (hService == NULL) + { + _tprintf(_T("[SC] OpenService FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + + if (!EnumDependentServices(hService, + SERVICE_STATE_ALL, + NULL, + 0, + &BufferSize, + &EntriesRead)) + { + if (BufferSize == 0) + { + _tprintf(_T("[SC] EnumDependentServices FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + } + + pBuffer = HeapAlloc(GetProcessHeap(), 0, BufferSize); + if (pBuffer == NULL) + { + SetLastError(ERROR_OUTOFMEMORY); + _tprintf(_T("[SC] HeapAlloc FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + + if (!EnumDependentServices(hService, + SERVICE_STATE_ALL, + pBuffer, + BufferSize, + &BufferSize, + &EntriesRead)) + { + _tprintf(_T("[SC] EnumDependentServices FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + + _tprintf(_T("Enum: entriesRead = %lu\n"), EntriesRead); + + for (i = 0; i < EntriesRead; i++) + { + _tprintf(_T("\n")); + _tprintf(_T("SERVICE_NAME: %s\n"), pBuffer[i].lpServiceName); + _tprintf(_T("DISPLAY_NAME: %s\n"), pBuffer[i].lpDisplayName); + PrintServiceStatus(&pBuffer[i].ServiceStatus); + } + +done: + if (bResult == FALSE) + ReportLastError(); + + if (pBuffer != NULL) + HeapFree(GetProcessHeap(), 0, pBuffer); + + if (hService) + CloseServiceHandle(hService); + + if (hManager) + CloseServiceHandle(hManager); + + return bResult; +} Propchange: trunk/reactos/base/applications/sc/depend.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/base/applications/sc/print.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/print…
============================================================================== --- trunk/reactos/base/applications/sc/print.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/print.c [iso-8859-1] Sat Jun 18 11:18:53 2016 @@ -102,3 +102,85 @@ _tprintf(_T("\n")); } + + +VOID +PrintServiceStatus( + LPSERVICE_STATUS pStatus) +{ + _tprintf(_T("\tTYPE : %x "), + (unsigned int)pStatus->dwServiceType); + switch (pStatus->dwServiceType) + { + case SERVICE_KERNEL_DRIVER: + _tprintf(_T("KERNEL_DRIVER\n")); + break; + + case SERVICE_FILE_SYSTEM_DRIVER: + _tprintf(_T("FILE_SYSTEM_DRIVER\n")); + break; + + case SERVICE_WIN32_OWN_PROCESS: + _tprintf(_T("WIN32_OWN_PROCESS\n")); + break; + + case SERVICE_WIN32_SHARE_PROCESS: + _tprintf(_T("WIN32_SHARE_PROCESS\n")); + break; + + case SERVICE_WIN32_OWN_PROCESS + SERVICE_INTERACTIVE_PROCESS: + _tprintf(_T("WIN32_OWN_PROCESS (interactive)\n")); + break; + + case SERVICE_WIN32_SHARE_PROCESS + SERVICE_INTERACTIVE_PROCESS: + _tprintf(_T("WIN32_SHARE_PROCESS (interactive)\n")); + break; + + default : _tprintf(_T("\n")); break; + } + + _tprintf(_T("\tSTATE : %x "), + (unsigned int)pStatus->dwCurrentState); + + switch (pStatus->dwCurrentState) + { + case 1 : _tprintf(_T("STOPPED\n")); break; + case 2 : _tprintf(_T("START_PENDING\n")); break; + case 3 : _tprintf(_T("STOP_PENDING\n")); break; + case 4 : _tprintf(_T("RUNNING\n")); break; + case 5 : _tprintf(_T("CONTINUE_PENDING\n")); break; + case 6 : _tprintf(_T("PAUSE_PENDING\n")); break; + case 7 : _tprintf(_T("PAUSED\n")); break; + default : _tprintf(_T("\n")); break; + } + + _tprintf(_T("\t\t\t\t(")); + + if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_STOP) + _tprintf(_T("STOPPABLE,")); + else + _tprintf(_T("NOT_STOPPABLE,")); + + if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) + _tprintf(_T("PAUSABLE,")); + else + _tprintf(_T("NOT_PAUSABLE,")); + + if (pStatus->dwControlsAccepted & SERVICE_ACCEPT_SHUTDOWN) + _tprintf(_T("ACCEPTS_SHUTDOWN")); + else + _tprintf(_T("IGNORES_SHUTDOWN")); + + _tprintf(_T(")\n")); + + _tprintf(_T("\tWIN32_EXIT_CODE : %u (0x%x)\n"), + (unsigned int)pStatus->dwWin32ExitCode, + (unsigned int)pStatus->dwWin32ExitCode); + _tprintf(_T("\tSERVICE_EXIT_CODE : %u (0x%x)\n"), + (unsigned int)pStatus->dwServiceSpecificExitCode, + (unsigned int)pStatus->dwServiceSpecificExitCode); + _tprintf(_T("\tCHECKPOINT : 0x%x\n"), + (unsigned int)pStatus->dwCheckPoint); + _tprintf(_T("\tWAIT_HINT : 0x%x\n"), + (unsigned int)pStatus->dwWaitHint); +} Modified: trunk/reactos/base/applications/sc/sc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/sc.c?…
============================================================================== --- trunk/reactos/base/applications/sc/sc.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/sc.c [iso-8859-1] Sat Jun 18 11:18:53 2016 @@ -296,6 +296,18 @@ else GetKeyNameUsage(); } + else if (!lstrcmpi(Command, _T("EnumDepend"))) + { + if (ArgCount > 0) + { + ServiceName = *ServiceArgs++; + ArgCount--; + + EnumDepend(ServiceName); + } + else + EnumDependUsage(); + } else { MainUsage(); Modified: trunk/reactos/base/applications/sc/sc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/sc.h?…
============================================================================== --- trunk/reactos/base/applications/sc/sc.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/sc.h [iso-8859-1] Sat Jun 18 11:18:53 2016 @@ -47,9 +47,11 @@ BOOL SetFailure(LPCTSTR *ServiceArgs, INT ArgCount); BOOL GetDisplayName(LPCTSTR ServiceName); BOOL GetKeyName(LPCTSTR ServiceName); +BOOL EnumDepend(LPCTSTR ServiceName); /* print and error functions */ VOID PrintService(LPCTSTR ServiceName, LPSERVICE_STATUS_PROCESS pStatus, BOOL bExtended); +VOID PrintServiceStatus(LPSERVICE_STATUS pStatus); VOID ReportLastError(VOID); /* misc.c */ @@ -87,5 +89,6 @@ VOID SetFailureUsage(VOID); VOID GetDisplayNameUsage(VOID); VOID GetKeyNameUsage(VOID); +VOID EnumDependUsage(VOID); #endif /* _SC_PCH_ */ Modified: trunk/reactos/base/applications/sc/usage.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/usage…
============================================================================== --- trunk/reactos/base/applications/sc/usage.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/usage.c [iso-8859-1] Sat Jun 18 11:18:53 2016 @@ -45,8 +45,8 @@ _T("\t sdshow : Displays a service's security descriptor.\n") _T("\t sdset : Sets a service's security descriptor.\n") _T("\t GetDisplayName : Gets the DisplayName for a service.\n") - _T("\t GetKeyName : Gets the ServiceKeyName for a service.\n")); -// "\t EnumDepend : Enumerates Service Dependencies.\n") + _T("\t GetKeyName : Gets the ServiceKeyName for a service.\n") + _T("\t EnumDepend : Enumerates Service Dependencies.\n")); // "\n") // "\tService Name Independant Commands:\n") // "\t boot : (ok | bad) Indicates whether the last boot should\n") @@ -279,3 +279,11 @@ _T("USAGE:\n") _T(" sc <server> GetKeyName <service display name> <bufsize>\n")); } + +VOID EnumDependUsage(VOID) +{ + _tprintf(_T("DESCRIPTION:\n") + _T(" Enumerates te Services that are dependent on this one.\n") + _T("USAGE:\n") + _T(" sc <server> EnumDepend <service display name> <bufsize>\n")); +}
8 years, 7 months
1
0
0
0
[zhu] 71652: TDI_SEND and TDI_RECEIVE handlers code-complete. None of it has been tested yet.
by zhu@svn.reactos.org
Author: zhu Date: Fri Jun 17 17:12:07 2016 New Revision: 71652 URL:
http://svn.reactos.org/svn/reactos?rev=71652&view=rev
Log: TDI_SEND and TDI_RECEIVE handlers code-complete. None of it has been tested yet. Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/CMakeLists.txt Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
============================================================================== --- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c [iso-8859-1] (original) +++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.c [iso-8859-1] Fri Jun 17 17:12:07 2016 @@ -27,6 +27,7 @@ static KSPIN_LOCK AddressListLock; static LIST_ENTRY AddressListHead; +/* implementation in testing */ NTSTATUS PrepareIrpForCancel( PIRP Irp, @@ -54,6 +55,7 @@ return Irp->IoStatus.Status; } +/* implementation in testing */ VOID NTAPI CancelRequestRoutine( @@ -235,6 +237,7 @@ pbuf_free(p); } +/* implementation in testing */ static err_t lwip_tcp_accept_callback( @@ -258,26 +261,112 @@ Irp->Cancel = FALSE; IoReleaseCancelSpinLock(OldIrql); - DPRINT1("\nnewpcb %08x\n", newpcb); - if (AddressFile->ConnectionContext) - { - if (AddressFile->ConnectionContext->lwip_tcp_pcb) + AddressFile->ConnectionContext->lwip_tcp_pcb = newpcb; + + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NETWORK_INCREMENT); + + return ERR_OK; +} + +/* implementation in testing */ +static +err_t +lwip_tcp_sent_callback( + void *arg, + struct tcp_pcb *tpcb, + u16_t len +) +{ + return ERR_OK; +} + +/* This implementation does not take into account any flags */ +static +err_t +lwip_tcp_receive_callback( + void *arg, + struct tcp_pcb *tpcb, + struct pbuf *p, + err_t err +) +{ + PIRP Irp; + PNDIS_BUFFER Buffer; + PIO_STACK_LOCATION IrpSp; + PTDI_REQUEST_KERNEL_RECEIVE ReceiveInfo; + KIRQL OldIrql; + + INT CopiedLength; + INT RemainingDestBytes; + INT RemainingSrceBytes; + UCHAR *CurrentDestLocation; + UCHAR *CurrentSrceLocation; + + DPRINT1("lwIP TCP Receive Callback\n"); + + Irp = (PIRP)arg; + + IoAcquireCancelSpinLock(&OldIrql); + IoSetCancelRoutine(Irp, NULL); + Irp->Cancel = FALSE; + IoReleaseCancelSpinLock(OldIrql); + + Buffer = (PNDIS_BUFFER)Irp->MdlAddress; + IrpSp = IoGetCurrentIrpStackLocation(Irp); + ReceiveInfo = (PTDI_REQUEST_KERNEL_RECEIVE)&IrpSp->Parameters; + + if (ReceiveInfo->ReceiveLength <= p->len) + { + RtlCopyMemory(Buffer, p->payload, ReceiveInfo->ReceiveLength); + CopiedLength = ReceiveInfo->ReceiveLength; + goto RETURN; + } + else + { + CopiedLength = 0; + RemainingDestBytes = ReceiveInfo->ReceiveLength; + RemainingSrceBytes = p->len; + CurrentDestLocation = (UCHAR*)Buffer; + CurrentSrceLocation = p->payload; + + while (1) { - DPRINT1("\nlwip_tcp_pcb %08x\n", AddressFile->ConnectionContext->lwip_tcp_pcb); + if (RemainingSrceBytes < RemainingDestBytes) + { + RtlCopyMemory(CurrentDestLocation, CurrentSrceLocation, RemainingSrceBytes); + + CopiedLength += p->len; + RemainingDestBytes -= p->len; + CurrentDestLocation += p->len; + + if (p->next) + { + RemainingSrceBytes = p->next->len; + CurrentSrceLocation = p->next->payload; + + p = p->next; + + continue; + } + else + { + goto RETURN; + } + } + else + { + RtlCopyMemory(CurrentDestLocation, CurrentSrceLocation, RemainingDestBytes); + CopiedLength += RemainingDestBytes; + + goto RETURN; + } } - else - { - DPRINT1("\nlwip_tcp_pcb is NULL\n"); - } - } - else - { - DPRINT1("ConnectionContext is NULL\n"); - } - - AddressFile->ConnectionContext->lwip_tcp_pcb = newpcb; - + } + +RETURN: Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = CopiedLength; IoCompleteRequest(Irp, IO_NETWORK_INCREMENT); return ERR_OK; @@ -328,6 +417,7 @@ return Result; } +/* implementation in testing */ static err_t lwip_tcp_Connected_callback( @@ -336,48 +426,28 @@ err_t err) { PIRP Irp; - PIO_STACK_LOCATION IrpSp; KIRQL OldIrql; - PADDRESS_FILE AddressFile; DPRINT1("lwIP TCP Connected Callback\n"); Irp = (PIRP)arg; - IrpSp = IoGetCurrentIrpStackLocation(Irp); - AddressFile = (PADDRESS_FILE)IrpSp->FileObject->FsContext; IoAcquireCancelSpinLock(&OldIrql); IoSetCancelRoutine(Irp, NULL); Irp->Cancel = FALSE; IoReleaseCancelSpinLock(OldIrql); - DPRINT1("\ntpcb %08x\n", tpcb); - if (AddressFile->ConnectionContext) - { - if (AddressFile->ConnectionContext->lwip_tcp_pcb) - { - DPRINT1("\nlwip_tcp_pcb %08x\n", AddressFile->ConnectionContext->lwip_tcp_pcb); - } - else - { - DPRINT1("\nlwip_tcp_pcb is NULL\n"); - } - } - else - { - DPRINT1("ConnectionContext is NULL\n"); - } - Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NETWORK_INCREMENT); return ERR_OK; } +/* implementation in testing */ NTSTATUS TcpIpCreateAddress( _Inout_ PIRP Irp, - _Inout_ PTDI_ADDRESS_IP Address, + _In_ PTDI_ADDRESS_IP Address, _In_ IPPROTO Protocol ) { @@ -552,15 +622,35 @@ return STATUS_SUCCESS; } +/* implementation in testing */ NTSTATUS TcpIpCreateContext( _Inout_ PIRP Irp, + _In_ PTDI_ADDRESS_IP Address, _In_ IPPROTO Protocol ) { PIO_STACK_LOCATION IrpSp; PTCP_CONTEXT Context; + ULONG *temp; + + IrpSp = IoGetCurrentIrpStackLocation(Irp); + + temp = (ULONG*)Address; + DPRINT1("\n TcpIpCreateAddress Input Dump\n %08x %08x %08x %08x\n", + temp[3], temp[2], + temp[1], temp[0]); + if (IrpSp->FileObject && IrpSp->FileObject->FsContext) + { + temp = IrpSp->FileObject->FsContext; + if (temp) { + DPRINT1("\n IrpSp Dump\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", + temp[7], temp[6], temp[5], temp[4], + temp[3], temp[2], temp[1], temp[0]); + } + } + Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(*Context), TAG_ADDRESS_FILE); if (!Context) { @@ -573,20 +663,20 @@ return STATUS_INVALID_PARAMETER; } Context->Protocol = Protocol; + Context->RequestAddress = *Address; Context->lwip_tcp_pcb = tcp_new(); if (Context->lwip_tcp_pcb == NULL) { return STATUS_NO_MEMORY; } - IrpSp = IoGetCurrentIrpStackLocation(Irp); - IrpSp->FileObject->FsContext = (PVOID)Context; IrpSp->FileObject->FsContext2 = (PVOID)TDI_CONNECTION_FILE; return STATUS_SUCCESS; } +/* implementation in testing */ NTSTATUS TcpIpCloseAddress( _Inout_ ADDRESS_FILE* AddressFile @@ -600,6 +690,7 @@ if (InterlockedDecrement(&AddressFile->RefCount) != 0) { /* There are still some open handles for this address */ + DPRINT1("TcpIpCloseAddress on address with open handles\n"); KeReleaseSpinLock(&AddressListLock, OldIrql); return STATUS_SUCCESS; } @@ -609,7 +700,10 @@ udp_remove(AddressFile->lwip_udp_pcb); else if (AddressFile->Protocol == IPPROTO_TCP && AddressFile->ConnectionContext) { - tcp_close(AddressFile->ConnectionContext->lwip_tcp_pcb); + if (AddressFile->ConnectionContext->lwip_tcp_pcb) + { + tcp_close(AddressFile->ConnectionContext->lwip_tcp_pcb); + } ExFreePoolWithTag(AddressFile->ConnectionContext, TAG_ADDRESS_FILE); } else if (AddressFile->Protocol == IPPROTO_RAW) @@ -742,8 +836,6 @@ AddressFile->ConnectionContext->lwip_tcp_pcb->local_ip, AddressFile->ConnectionContext->lwip_tcp_pcb->local_port); - PrepareIrpForCancel(Irp, CancelRequestRoutine); - lwip_err = tcp_connect(AddressFile->ConnectionContext->lwip_tcp_pcb, (ip_addr_t *)&SocketAddressInRemote->sin_addr.s_addr, SocketAddressInRemote->sin_port, @@ -753,35 +845,42 @@ { case (ERR_VAL) : { + DPRINT1("lwip ERR_VAL\n"); return STATUS_INVALID_PARAMETER; } case (ERR_ISCONN) : { + DPRINT1("lwip ERR_ISCONN\n"); return STATUS_CONNECTION_ACTIVE; } case (ERR_RTE) : { /* several errors look right here */ + DPRINT1("lwip ERR_RTE\n"); return STATUS_NETWORK_UNREACHABLE; } case (ERR_BUF) : { /* use correct error once NDIS errors are included this return value means local port unavailable */ + DPRINT1("lwip ERR_BUF\n"); return STATUS_ADDRESS_ALREADY_EXISTS; } case (ERR_USE) : { /* STATUS_CONNECTION_ACTIVE maybe? */ + DPRINT1("lwip ERR_USE\n"); return STATUS_ADDRESS_ALREADY_EXISTS; } case (ERR_MEM) : { + DPRINT1("lwip ERR_MEM\n"); return STATUS_NO_MEMORY; } case (ERR_OK) : { DPRINT1("lwip ERR_OK\n"); + PrepareIrpForCancel(Irp, CancelRequestRoutine); tcp_arg(AddressFile->ConnectionContext->lwip_tcp_pcb, Irp); break; } @@ -852,6 +951,7 @@ if (AddressFile->Address.in_addr == 0) { + // should really look through address file list for an interface AddressFile->Address.in_addr = 0x0100007f; } @@ -860,10 +960,12 @@ AddressFile->Address.in_addr); /* Finally calling into lwip to perform socket bind */ + ip_set_option(Context->lwip_tcp_pcb, SOF_REUSEADDR); lwip_err = tcp_bind( Context->lwip_tcp_pcb, (ip_addr_t *)&AddressFile->Address.in_addr, AddressFile->Address.sin_port); + ip_set_option(Context->lwip_tcp_pcb, SOF_BROADCAST); DPRINT1("lwip error %d\n TCP PCB:\n Local Address: %08x\n Local Port: %04x\n Remote Address: %08x\n Remote Port: %04x\n", lwip_err, Context->lwip_tcp_pcb->local_ip, @@ -909,7 +1011,6 @@ } } } - ip_set_option(Context->lwip_tcp_pcb, SOF_BROADCAST); Context->AddressFile = AddressFile; AddressFile->ConnectionContext = Context; @@ -996,7 +1097,7 @@ either INVALID_ADDRESS or NO_MEMORY if SO_REUSE is enabled in lwip options */ DPRINT1("lwip tcp_listen error\n"); - return STATUS_NO_MEMORY; + return STATUS_INVALID_ADDRESS; } else { @@ -1007,6 +1108,111 @@ tcp_accept(ConnectionContext->lwip_tcp_pcb, lwip_tcp_accept_callback); tcp_arg(ConnectionContext->lwip_tcp_pcb, Irp); + + return STATUS_PENDING; +} + +NTSTATUS +TcpIpSend( + _Inout_ PIRP Irp) +{ + PIO_STACK_LOCATION IrpSp; + PTDI_REQUEST_KERNEL_SEND Request; + PADDRESS_FILE AddressFile; + PTCP_CONTEXT Context; + PNDIS_BUFFER Buffer; + + err_t lwip_err; + + IrpSp = IoGetCurrentIrpStackLocation(Irp); + Request = (PTDI_REQUEST_KERNEL_SEND)&IrpSp->Parameters; + + if (IrpSp->FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) + { + DPRINT1("TcpIpSend without a TDI_TRANSPORT_ADDRESS_FILE\n"); + return STATUS_INVALID_PARAMETER; + } + AddressFile = IrpSp->FileObject->FsContext; + + if (!AddressFile->ConnectionContext) + { + DPRINT1("TcpIpSend with no TCP_CONTEXT\n"); + return STATUS_INVALID_PARAMETER; + } + Context = AddressFile->ConnectionContext; + + if (!Irp->MdlAddress) + { + DPRINT1("TcpIpSendEmpty\n"); + return STATUS_INVALID_PARAMETER; + } + Buffer = (PNDIS_BUFFER)Irp->MdlAddress; + + if (!Context->lwip_tcp_pcb) + { + DPRINT1("TcpIpSend with no lwIP tcp_pcb\n"); + return STATUS_INVALID_PARAMETER; + } + + lwip_err = tcp_write(Context->lwip_tcp_pcb, Buffer, Request->SendLength, 0); + switch (lwip_err) + { + case ERR_OK: + DPRINT1("lwIP ERR_OK\n"); + break; + case ERR_MEM: + DPRINT1("lwIP ERR_MEM\n"); + return STATUS_NO_MEMORY; + case ERR_ARG: + DPRINT1("lwIP ERR_ARG\n"); + return STATUS_INVALID_PARAMETER; + case ERR_CONN: + DPRINT1("lwIP ERR_CONN\n"); + return STATUS_CONNECTION_ACTIVE; + default: + DPRINT1("Unknwon lwIP Error: %d\n", lwip_err); + return STATUS_NOT_IMPLEMENTED; + } + + tcp_arg(Context->lwip_tcp_pcb, Irp); + tcp_sent(Context->lwip_tcp_pcb, lwip_tcp_sent_callback); + + return STATUS_PENDING; +} + +NTSTATUS +TcpIpReceive( + _Inout_ PIRP Irp) +{ + PIO_STACK_LOCATION IrpSp; + PADDRESS_FILE AddressFile; + PTCP_CONTEXT Context; + + IrpSp = IoGetCurrentIrpStackLocation(Irp); + + if (IrpSp->FileObject->FsContext2 != (PVOID)TDI_TRANSPORT_ADDRESS_FILE) + { + DPRINT1("TcpIpReceive on something that is not an address file\n"); + return STATUS_INVALID_PARAMETER; + } + AddressFile = IrpSp->FileObject->FsContext; + + if (!AddressFile->ConnectionContext) + { + DPRINT1("Receiving on TCP address file with no connection context\n"); + return STATUS_INVALID_ADDRESS; + } + Context = AddressFile->ConnectionContext; + + if (!Context->lwip_tcp_pcb) + { + DPRINT1("Connection context does not contain a lwIP tcp_pcb\n"); + return STATUS_INVALID_ADDRESS; + } + + PrepareIrpForCancel(Irp, CancelRequestRoutine); + tcp_recv(Context->lwip_tcp_pcb, lwip_tcp_receive_callback); + tcp_arg(Context->lwip_tcp_pcb, Irp); return STATUS_PENDING; } Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
============================================================================== --- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h [iso-8859-1] (original) +++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/address.h [iso-8859-1] Fri Jun 17 17:12:07 2016 @@ -21,6 +21,7 @@ ADDRESS_FILE *AddressFile; LIST_ENTRY ListEntry; IPPROTO Protocol; + TDI_ADDRESS_IP RequestAddress; LONG RefCount; KSPIN_LOCK Lock; KIRQL OldIrql; @@ -40,6 +41,7 @@ NTSTATUS TcpIpCreateContext( _Inout_ PIRP Irp, + _In_ PTDI_ADDRESS_IP Address, _In_ IPPROTO Protocol ); @@ -65,12 +67,22 @@ NTSTATUS TcpIpListen( - _Inout_ PIRP Irp); + _Inout_ PIRP Irp +); + +NTSTATUS +TcpIpReceive( + _Inout_ PIRP Irp +); NTSTATUS TcpIpReceiveDatagram( _Inout_ PIRP Irp); +NTSTATUS +TcpIpSend( + _Inout_ PIRP Irp); + NTSTATUS TcpIpSendDatagram( _Inout_ PIRP Irp); Modified: branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/drivers/ne…
============================================================================== --- branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c [iso-8859-1] (original) +++ branches/GSoC_2016/lwIP-tcpip/drivers/network/tcpip/main.c [iso-8859-1] Fri Jun 17 17:12:07 2016 @@ -316,7 +316,7 @@ DPRINT1("\n PTA_IP_ADDRESS dump before\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", temp[7], temp[6], temp[5], temp[4], temp[3], temp[2], temp[1], temp[0]); - Status = TcpIpCreateContext(Irp, Protocol); + Status = TcpIpCreateContext(Irp, &Address->Address[0].Address[0], Protocol); DPRINT1("\n PTA_IP_ADDRESS dump after\n %08x %08x %08x %08x\n %08x %08x %08x %08x\n", temp[7], temp[6], temp[5], temp[4], temp[3], temp[2], temp[1], temp[0]); @@ -399,25 +399,62 @@ { NTSTATUS Status; PIO_STACK_LOCATION IrpSp; + PADDRESS_FILE AddressFile; DPRINT1("TcpIpDispatchInternal\n"); IrpSp = IoGetCurrentIrpStackLocation(Irp); + AddressFile = IrpSp->FileObject->FsContext; + switch (IrpSp->MinorFunction) { case TDI_RECEIVE: DPRINT1("TCPIP: TDI_RECEIVE!\n"); - Status = STATUS_NOT_IMPLEMENTED; - break; - + switch (AddressFile->Protocol) + { + case IPPROTO_TCP: + Status = TcpIpReceive(Irp); + break; + case IPPROTO_UDP: + Status = STATUS_NOT_IMPLEMENTED; + break; + case IPPROTO_RAW: + Status = STATUS_NOT_IMPLEMENTED; + break; + default: + Status = STATUS_NOT_IMPLEMENTED; + } + if (Status == STATUS_NOT_IMPLEMENTED) + { + DPRINT1("Received TDI_RECEIVE for non-TCP protocol\n"); + + } + break; case TDI_RECEIVE_DATAGRAM: DPRINT1("TCPIP: TDI_RECEIVE_DATAGRAM!\n"); return TcpIpReceiveDatagram(Irp); case TDI_SEND: DPRINT1("TCPIP: TDI_SEND!\n"); - Status = STATUS_NOT_IMPLEMENTED; + switch (AddressFile->Protocol) + { + case IPPROTO_TCP: + Status = TcpIpSend(Irp); + break; + case IPPROTO_UDP: + Status = STATUS_NOT_IMPLEMENTED; + break; + case IPPROTO_RAW: + Status = STATUS_NOT_IMPLEMENTED; + break; + default: + Status = STATUS_NOT_IMPLEMENTED; + } + if (Status == STATUS_NOT_IMPLEMENTED) + { + DPRINT1("Received TDI_SEND for non-TCP protocol\n"); + } break; case TDI_SEND_DATAGRAM: Modified: branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/lwIP-tcpip/sdk/lib/dr…
============================================================================== --- branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/CMakeLists.txt [iso-8859-1] (original) +++ branches/GSoC_2016/lwIP-tcpip/sdk/lib/drivers/CMakeLists.txt [iso-8859-1] Fri Jun 17 17:12:07 2016 @@ -2,7 +2,7 @@ add_subdirectory(chew) add_subdirectory(csq) add_subdirectory(hidparser) -add_subdirectory(ip) +#add_subdirectory(ip) add_subdirectory(libusb) add_subdirectory(lwip) add_subdirectory(ntoskrnl_vista)
8 years, 7 months
1
0
0
0
[ekohl] 71651: [SC] Add GetKeyName command.
by ekohl@svn.reactos.org
Author: ekohl Date: Thu Jun 16 21:18:59 2016 New Revision: 71651 URL:
http://svn.reactos.org/svn/reactos?rev=71651&view=rev
Log: [SC] Add GetKeyName command. Modified: trunk/reactos/base/applications/sc/name.c trunk/reactos/base/applications/sc/sc.c trunk/reactos/base/applications/sc/sc.h trunk/reactos/base/applications/sc/usage.c Modified: trunk/reactos/base/applications/sc/name.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/name.…
============================================================================== --- trunk/reactos/base/applications/sc/name.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/name.c [iso-8859-1] Thu Jun 16 21:18:59 2016 @@ -73,3 +73,68 @@ return bResult; } + +BOOL GetKeyName(LPCTSTR ServiceName) +{ + SC_HANDLE hManager = NULL; + BOOL bResult = TRUE; + DWORD BufferSize = 0; + LPTSTR pBuffer = NULL; + + hManager = OpenSCManager(NULL, + NULL, + SC_MANAGER_CONNECT); + if (hManager == NULL) + { + _tprintf(_T("[SC] OpenSCManager FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + + if (!GetServiceKeyName(hManager, + ServiceName, + NULL, + &BufferSize)) + { + if (BufferSize == 0) + { + _tprintf(_T("[SC] GetServiceKeyName FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + } + + pBuffer = HeapAlloc(GetProcessHeap(), 0, (BufferSize + 1) * sizeof(TCHAR)); + if (pBuffer == NULL) + { + SetLastError(ERROR_OUTOFMEMORY); + _tprintf(_T("[SC] HeapAlloc FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + + BufferSize++; + if (!GetServiceKeyName(hManager, + ServiceName, + pBuffer, + &BufferSize)) + { + _tprintf(_T("[SC] GetServiceKeyName FAILED %lu:\n\n"), GetLastError()); + bResult = FALSE; + goto done; + } + + _tprintf(_T("[SC] GetServiceKeyName SUCCESS Name = %s\n"), pBuffer); + +done: + if (bResult == FALSE) + ReportLastError(); + + if (pBuffer != NULL) + HeapFree(GetProcessHeap(), 0, pBuffer); + + if (hManager) + CloseServiceHandle(hManager); + + return bResult; +} Modified: trunk/reactos/base/applications/sc/sc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/sc.c?…
============================================================================== --- trunk/reactos/base/applications/sc/sc.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/sc.c [iso-8859-1] Thu Jun 16 21:18:59 2016 @@ -284,6 +284,18 @@ else GetDisplayNameUsage(); } + else if (!lstrcmpi(Command, _T("GetKeyName"))) + { + if (ArgCount > 0) + { + ServiceName = *ServiceArgs++; + ArgCount--; + + GetKeyName(ServiceName); + } + else + GetKeyNameUsage(); + } else { MainUsage(); Modified: trunk/reactos/base/applications/sc/sc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/sc.h?…
============================================================================== --- trunk/reactos/base/applications/sc/sc.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/sc.h [iso-8859-1] Thu Jun 16 21:18:59 2016 @@ -46,6 +46,7 @@ BOOL QueryFailure(LPCTSTR ServiceName); BOOL SetFailure(LPCTSTR *ServiceArgs, INT ArgCount); BOOL GetDisplayName(LPCTSTR ServiceName); +BOOL GetKeyName(LPCTSTR ServiceName); /* print and error functions */ VOID PrintService(LPCTSTR ServiceName, LPSERVICE_STATUS_PROCESS pStatus, BOOL bExtended); @@ -85,5 +86,6 @@ VOID SetConfigUsage(VOID); VOID SetFailureUsage(VOID); VOID GetDisplayNameUsage(VOID); +VOID GetKeyNameUsage(VOID); #endif /* _SC_PCH_ */ Modified: trunk/reactos/base/applications/sc/usage.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/usage…
============================================================================== --- trunk/reactos/base/applications/sc/usage.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/usage.c [iso-8859-1] Thu Jun 16 21:18:59 2016 @@ -44,8 +44,8 @@ _T("\t control : Sends a control to a service.\n") _T("\t sdshow : Displays a service's security descriptor.\n") _T("\t sdset : Sets a service's security descriptor.\n") - _T("\t GetDisplayName : Gets the DisplayName for a service.\n")); -// "\t GetKeyName : Gets the ServiceKeyName for a service.\n") + _T("\t GetDisplayName : Gets the DisplayName for a service.\n") + _T("\t GetKeyName : Gets the ServiceKeyName for a service.\n")); // "\t EnumDepend : Enumerates Service Dependencies.\n") // "\n") // "\tService Name Independant Commands:\n") @@ -266,7 +266,16 @@ VOID GetDisplayNameUsage(VOID) { _tprintf(_T("DESCRIPTION:\n") - _T(" Gets the display name associated with a particular service\n") + _T(" Gets the display name associated with a particular service.\n") _T("USAGE:\n") _T(" sc <server> GetDisplayName <service key name> <bufsize>\n")); } + +VOID GetKeyNameUsage(VOID) +{ + _tprintf(_T("DESCRIPTION:\n") + _T(" Gets the key name associated with a particular service, using the\n") + _T(" display name as input.\n") + _T("USAGE:\n") + _T(" sc <server> GetKeyName <service display name> <bufsize>\n")); +}
8 years, 7 months
1
0
0
0
[apriyadarshi] 71650: fixed portCount boundary problem :D
by apriyadarshi@svn.reactos.org
Author: apriyadarshi Date: Thu Jun 16 21:14:03 2016 New Revision: 71650 URL:
http://svn.reactos.org/svn/reactos?rev=71650&view=rev
Log: fixed portCount boundary problem :D Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.c [iso-8859-1] Thu Jun 16 21:14:03 2016 @@ -35,7 +35,7 @@ portNumber = PortExtension->PortNumber; NT_ASSERT(abar != NULL); - NT_ASSERT(portNumber < MAXIMUM_AHCI_PORT_COUNT); + NT_ASSERT(portNumber < adapterExtension->PortCount); PortExtension->Port = &abar->PortList[portNumber]; @@ -120,18 +120,15 @@ portCount = 0; portImplemented = AdapterExtension->PortImplemented; - // make sure we don't allocate too much memory for the ports we have not implemented - // LOGIC: AND with all MAXIMUM_AHCI_PORT_COUNT (low significant) bits set - portImplemented = portImplemented & ((1 << MAXIMUM_AHCI_PORT_COUNT) - 1); - while (portImplemented > 0) - { - portCount++; - portImplemented &= (portImplemented - 1); - } - - NT_ASSERT(portCount <= MAXIMUM_AHCI_PORT_COUNT); + NT_ASSERT(portImplemented != 0); + for (index = MAXIMUM_AHCI_PORT_COUNT - 1; index > 0; index--) + if ((portImplemented & (1 << index)) != 0) + break; + + portCount = index + 1; DebugPrint("\tPort Count: %d\n", portCount); + AdapterExtension->PortCount = portCount; nonCachedExtensionSize = sizeof(AHCI_COMMAND_HEADER) * AlignedNCS + //should be 1K aligned sizeof(AHCI_RECEIVED_FIS); @@ -151,7 +148,7 @@ nonCachedExtension = AdapterExtension->NonCachedExtension; AhciZeroMemory(nonCachedExtension, nonCachedExtensionSize * portCount); - for (index = 0; index < MAXIMUM_AHCI_PORT_COUNT; index++) + for (index = 0; index < portCount; index++) { AdapterExtension->PortExtension[index].IsActive = FALSE; if ((AdapterExtension->PortImplemented & (1 << index)) != 0) @@ -298,7 +295,7 @@ * * The Storport driver calls the HwStorInterrupt routine after the HBA generates an interrupt request. * - * @param adapterExtension + * @param AdapterExtension * * @return * return TRUE Indicates that an interrupt was pending on adapter. @@ -306,48 +303,46 @@ */ BOOLEAN AhciHwInterrupt( - __in PVOID AdapterExtension - ) -{ - ULONG portPending, nextPort, i; - PAHCI_ADAPTER_EXTENSION adapterExtension; + __in PAHCI_ADAPTER_EXTENSION AdapterExtension + ) +{ + ULONG portPending, nextPort, i, portCount; DebugPrint("AhciHwInterrupt()\n"); - adapterExtension = AdapterExtension; - - if (adapterExtension->StateFlags.Removed) + if (AdapterExtension->StateFlags.Removed) { return FALSE; } - portPending = StorPortReadRegisterUlong(adapterExtension, adapterExtension->IS); + portPending = StorPortReadRegisterUlong(AdapterExtension, AdapterExtension->IS); // we process interrupt for implemented ports only - portPending = portPending & adapterExtension->PortImplemented; + portCount = AdapterExtension->PortCount; + portPending = portPending & AdapterExtension->PortImplemented; if (portPending == 0) { return FALSE; } - for (i = 1; i <= MAXIMUM_AHCI_PORT_COUNT; i++) - { - nextPort = (adapterExtension->LastInterruptPort + i) % MAXIMUM_AHCI_PORT_COUNT; + for (i = 1; i <= portCount; i++) + { + nextPort = (AdapterExtension->LastInterruptPort + i) % portCount; if ((portPending & (0x1 << nextPort)) == 0) continue; NT_ASSERT(IsPortValid(AdapterExtension, nextPort)); - if ((nextPort == adapterExtension->LastInterruptPort) || - (adapterExtension->PortExtension[nextPort].IsActive == FALSE)) + if ((nextPort == AdapterExtension->LastInterruptPort) || + (AdapterExtension->PortExtension[nextPort].IsActive == FALSE)) { return FALSE; } // we can assign this interrupt to this port - adapterExtension->LastInterruptPort = nextPort; - AhciInterruptHandler(&adapterExtension->PortExtension[nextPort]); + AdapterExtension->LastInterruptPort = nextPort; + AhciInterruptHandler(&AdapterExtension->PortExtension[nextPort]); // interrupt belongs to this device // should always return TRUE @@ -448,19 +443,22 @@ if (cdb->CDB10.OperationCode == SCSIOP_INQUIRY) { Srb->SrbStatus = DeviceInquiryRequest(adapterExtension, Srb, cdb); - StorPortNotification(RequestComplete, adapterExtension, Srb); - return TRUE; + } + else + { + Srb->SrbStatus = SRB_STATUS_NO_DEVICE; } } else { Srb->SrbStatus = SRB_STATUS_BAD_FUNCTION; - StorPortNotification(RequestComplete, adapterExtension, Srb); - return TRUE; } - } - - DebugPrint("\tUnknow function code recieved: %x\n", function); + + StorPortNotification(RequestComplete, adapterExtension, Srb); + return TRUE; + } + + DebugPrint("\tUnknown function code recieved: %x\n", function); Srb->SrbStatus = SRB_STATUS_BAD_FUNCTION; StorPortNotification(RequestComplete, adapterExtension, Srb); return TRUE; @@ -672,7 +670,7 @@ return SP_RETURN_ERROR; } - for (index = 0; index < MAXIMUM_AHCI_PORT_COUNT; index++) + for (index = 0; index < adapterExtension->PortCount; index++) { if ((adapterExtension->PortImplemented & (0x1<<index)) != 0) AhciPortInitialize(&adapterExtension->PortExtension[index]); @@ -812,7 +810,7 @@ PortExtension = &AdapterExtension->PortExtension[PathId]; - NT_ASSERT(PathId < MAXIMUM_AHCI_PORT_COUNT); + NT_ASSERT(PathId < AdapterExtension->PortCount); // add Srb to queue AddQueue(&PortExtension->SrbQueue, Srb); @@ -1021,7 +1019,7 @@ { NT_ASSERT(pathId >= 0); - if (pathId >= MAXIMUM_AHCI_PORT_COUNT) + if (pathId >= AdapterExtension->PortCount) { return FALSE; } Modified: branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/AHCI/drivers/storage/…
============================================================================== --- branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] (original) +++ branches/GSoC_2016/AHCI/drivers/storage/storahci/storahci.h [iso-8859-1] Thu Jun 16 21:14:03 2016 @@ -10,7 +10,7 @@ #define DEBUG 1 -#define MAXIMUM_AHCI_PORT_COUNT 12 +#define MAXIMUM_AHCI_PORT_COUNT 25 #define MAXIMUM_QUEUE_BUFFER_SIZE 255 #define MAXIMUM_TRANSFER_LENGTH (128*1024) // 128 KB @@ -20,6 +20,7 @@ #define AHCI_Global_HBA_CONTROL_MRSM (1 << 2) #define AHCI_Global_HBA_CONTROL_AE (1 << 31) #define AHCI_Global_HBA_CAP_S64A (1 << 31) +#define AHCI_Global_Port_CMD_IDLE ((1 << 0) | (1 << 4) | (1 << 14) | (1 << 15)) // PxCMD.ST, PxCMD.CR, PxCMD.FRE and PxCMD.FR // 3.1.1 NCS = CAP[12:08] -> Align #define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8) @@ -254,6 +255,7 @@ ULONG AhciBaseAddress; PULONG IS;// Interrupt Status, In case of MSIM == `1` ULONG PortImplemented;// bit-mapping of ports which are implemented + ULONG PortCount; USHORT VendorID; USHORT DeviceID;
8 years, 7 months
1
0
0
0
[mjansen] 71649: [MSGINA_APITEST] Add a test for ShellDimScreen, used to fade out the background of the logoff dialog. Thanks to Jared for finding the api, and Hermès for his help! CORE-11422
by mjansen@svn.reactos.org
Author: mjansen Date: Thu Jun 16 21:00:08 2016 New Revision: 71649 URL:
http://svn.reactos.org/svn/reactos?rev=71649&view=rev
Log: [MSGINA_APITEST] Add a test for ShellDimScreen, used to fade out the background of the logoff dialog. Thanks to Jared for finding the api, and Hermès for his help! CORE-11422 Added: trunk/rostests/apitests/msgina/ trunk/rostests/apitests/msgina/CMakeLists.txt (with props) trunk/rostests/apitests/msgina/ShellDimScreen.cpp (with props) trunk/rostests/apitests/msgina/testlist.c (with props) Modified: trunk/rostests/apitests/CMakeLists.txt Modified: trunk/rostests/apitests/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/CMakeLists.txt?r…
============================================================================== --- trunk/rostests/apitests/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/CMakeLists.txt [iso-8859-1] Thu Jun 16 21:00:08 2016 @@ -14,6 +14,7 @@ if(NOT ARCH STREQUAL "amd64") add_subdirectory(kernel32) endif() +add_subdirectory(msgina) add_subdirectory(msvcrt) add_subdirectory(ntdll) add_subdirectory(ole32) Added: trunk/rostests/apitests/msgina/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msgina/CMakeList…
============================================================================== --- trunk/rostests/apitests/msgina/CMakeLists.txt (added) +++ trunk/rostests/apitests/msgina/CMakeLists.txt [iso-8859-1] Thu Jun 16 21:00:08 2016 @@ -0,0 +1,13 @@ + +set_cpp(WITH_RUNTIME) + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl) + +add_executable(msgina_apitest + ShellDimScreen.cpp + testlist.c) + +target_link_libraries(msgina_apitest wine uuid) +set_module_type(msgina_apitest win32cui) +add_importlibs(msgina_apitest msvcrt user32 kernel32) +add_cd_file(TARGET msgina_apitest DESTINATION reactos/bin FOR all) Propchange: trunk/rostests/apitests/msgina/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/apitests/msgina/ShellDimScreen.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msgina/ShellDimS…
============================================================================== --- trunk/rostests/apitests/msgina/ShellDimScreen.cpp (added) +++ trunk/rostests/apitests/msgina/ShellDimScreen.cpp [iso-8859-1] Thu Jun 16 21:00:08 2016 @@ -0,0 +1,114 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory + * PURPOSE: Test for ShellDimScreen + * PROGRAMMER: Mark Jansen + */ + +#include <apitest.h> +#include <atlbase.h> +#include <atlcom.h> + +#define INITGUID +#include <guiddef.h> +// stolen from com_apitest.h +DEFINE_GUID(CLSID_FadeTask, 0x7EB5FBE4, 0x2100, 0x49E6, 0x85, 0x93, 0x17, 0xE1, 0x30, 0x12, 0x2F, 0x91); + + +typedef HRESULT (__stdcall *tShellDimScreen) (IUnknown** Unknown, HWND* hWindow); + +tShellDimScreen ShellDimScreen; + +static void Test_Dim() +{ + IUnknown* unk = (IUnknown*)0xdeadbeef; + HWND wnd = (HWND)0xdeadbeef; + ULONG count; + + HRESULT hr = ShellDimScreen(NULL, NULL); + ok_hex(hr, E_INVALIDARG); + + hr = ShellDimScreen(&unk, &wnd); + ok_hex(hr, S_OK); + ok(unk != ((IUnknown*)0xdeadbeef), "Expected a valid object\n"); + ok(wnd != ((HWND)0xdeadbeef), "Expected a valid window ptr\n"); + ok(IsWindow(wnd), "Expected a valid window\n"); + ok(IsWindowVisible(wnd), "Expected the window to be visible\n"); + + if (unk != ((IUnknown*)0xdeadbeef) && unk) + { + count = unk->Release(); + ok(count == 0, "Expected count to be 0, was: %lu\n", count); + ok(!IsWindow(wnd), "Expected the window to be destroyed\n"); + } + + unk = (IUnknown*)0xdeadbeef; + wnd = (HWND)0xdeadbeef; + hr = ShellDimScreen(&unk, &wnd); + ok_hex(hr, S_OK); + ok(unk != ((IUnknown*)0xdeadbeef), "Expected a valid object\n"); + ok(wnd != ((HWND)0xdeadbeef), "Expected a valid window ptr\n"); + ok(IsWindow(wnd), "Expected a valid window\n"); + ok(IsWindowVisible(wnd), "Expected the window to be visible\n"); + char classname[100] = {0};; + int nRet = GetClassNameA(wnd, classname, 100); + ok(nRet == 17, "Expected GetClassName to return 3 was %i\n", nRet); + ok(!strcmp(classname, "DimmedWindowClass"), "Expected classname to be DimmedWindowClass, was %s\n", classname); + LONG style = GetWindowLong(wnd, GWL_STYLE); + LONG expectedstyle = WS_POPUP | WS_VISIBLE | WS_DISABLED | WS_CLIPSIBLINGS; + ok(style == expectedstyle, "Expected style to be %lx, was %lx\n", expectedstyle, style); + style = GetWindowLong(wnd, GWL_EXSTYLE); + ok(style == WS_EX_TOPMOST, "Expected exstyle to be %x, was %lx\n", WS_EX_TOPMOST, style); + + if (unk != ((IUnknown*)0xdeadbeef) && unk) + { + count = unk->AddRef(); + ok(count == 2, "Expected count to be 2, was: %lu\n", count); + count = unk->Release(); + ok(count == 1, "Expected count to be 1, was: %lu\n", count); + + IUnknown* unk2; + hr = unk->QueryInterface(IID_IUnknown, (void**)&unk2); + ok_hex(hr, S_OK); + if (SUCCEEDED(hr)) + { + ok(unk2 == unk, "Expected the object to be the same, was: %p, %p\n", unk, unk2); + unk2->Release(); + } + hr = unk->QueryInterface(CLSID_FadeTask, (void**)&unk2); + ok_hex(hr, E_NOINTERFACE); + if (SUCCEEDED(hr)) + { + ok(unk2 == unk, "Expected the object to be the same, was: %p, %p\n", unk, unk2); + unk2->Release(); + } + } + + RECT rc; + GetWindowRect(wnd, &rc); + + ok(rc.left == GetSystemMetrics(SM_XVIRTUALSCREEN), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_XVIRTUALSCREEN), rc.left); + ok(rc.top == GetSystemMetrics(SM_YVIRTUALSCREEN), "Expected rc.top to be %u, was %lu\n", GetSystemMetrics(SM_YVIRTUALSCREEN), rc.top); + ok((rc.right - rc.left) == GetSystemMetrics(SM_CXVIRTUALSCREEN), "Expected rc.left to be %u, was %lu\n", GetSystemMetrics(SM_CXVIRTUALSCREEN), (rc.right - rc.left)); + ok((rc.bottom - rc.top) == GetSystemMetrics(SM_CYVIRTUALSCREEN), "Expected rc.top to be %u, was %lu\n", GetSystemMetrics(SM_CYVIRTUALSCREEN), (rc.bottom - rc.top)); + + if (unk != ((IUnknown*)0xdeadbeef) && unk) + { + count = unk->Release(); + ok(count == 0, "Expected count to be 0, was: %lu\n", count); + ok(!IsWindow(wnd), "Expected the window to be destroyed\n"); + } +} + + +START_TEST(ShellDimScreen) +{ + HMODULE dll = LoadLibraryA("msgina.dll"); + ShellDimScreen = (tShellDimScreen)GetProcAddress(dll, MAKEINTRESOURCEA(16)); + if (!dll || !ShellDimScreen) + { + skip("msgina!#16 not found, skipping tests\n"); + return; + } + Test_Dim(); +} Propchange: trunk/rostests/apitests/msgina/ShellDimScreen.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/rostests/apitests/msgina/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/msgina/testlist.…
============================================================================== --- trunk/rostests/apitests/msgina/testlist.c (added) +++ trunk/rostests/apitests/msgina/testlist.c [iso-8859-1] Thu Jun 16 21:00:08 2016 @@ -0,0 +1,10 @@ +#define STANDALONE +#include <apitest.h> + +extern void func_ShellDimScreen(void); + +const struct test winetest_testlist[] = +{ + { "ShellDimScreen", func_ShellDimScreen }, + { 0, 0 } +}; Propchange: trunk/rostests/apitests/msgina/testlist.c ------------------------------------------------------------------------------ svn:eol-style = native
8 years, 7 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
...
23
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
Results per page:
10
25
50
100
200