mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-20 12:14:27 +02:00
Nt32Pkg: Fix SnpNt32 GetStatus bug
According to UEFI spec, the Snp.GetStatus should return the recycled transmit buffer address, while the NT32 SNP always return value 1 for the Txbuffer. Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zhang@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
This commit is contained in:
parent
50a65824c7
commit
a2cc5fea44
@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
|
|
||||||
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -44,6 +44,9 @@ SNPNT32_GLOBAL_DATA gSnpNt32GlobalData = {
|
|||||||
0,
|
0,
|
||||||
EfiLockUninitialized
|
EfiLockUninitialized
|
||||||
}, // Lock
|
}, // Lock
|
||||||
|
NULL, // RecycledTxBuf
|
||||||
|
0, // RecycledTxBufCount
|
||||||
|
32, // MaxRecycledTxBuf
|
||||||
//
|
//
|
||||||
// Private functions
|
// Private functions
|
||||||
//
|
//
|
||||||
@ -861,9 +864,20 @@ SnpNt32GetStatus (
|
|||||||
OUT VOID **TxBuffer
|
OUT VOID **TxBuffer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
SNPNT32_INSTANCE_DATA *Instance;
|
||||||
|
SNPNT32_GLOBAL_DATA *GlobalData;
|
||||||
|
|
||||||
|
Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
|
||||||
|
|
||||||
|
GlobalData = Instance->GlobalData;
|
||||||
|
|
||||||
if (TxBuffer != NULL) {
|
if (TxBuffer != NULL) {
|
||||||
*((UINT8 **) TxBuffer) = (UINT8 *)(UINTN) 1;
|
if (GlobalData->RecycledTxBufCount != 0) {
|
||||||
|
GlobalData->RecycledTxBufCount --;
|
||||||
|
*((UINT8 **) TxBuffer) = (UINT8 *) (UINTN)GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount];
|
||||||
|
} else {
|
||||||
|
*((UINT8 **) TxBuffer) = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InterruptStatus != NULL) {
|
if (InterruptStatus != NULL) {
|
||||||
@ -918,6 +932,7 @@ SnpNt32Transmit (
|
|||||||
SNPNT32_INSTANCE_DATA *Instance;
|
SNPNT32_INSTANCE_DATA *Instance;
|
||||||
SNPNT32_GLOBAL_DATA *GlobalData;
|
SNPNT32_GLOBAL_DATA *GlobalData;
|
||||||
INT32 ReturnValue;
|
INT32 ReturnValue;
|
||||||
|
UINT64 *Tmp;
|
||||||
|
|
||||||
Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
|
Instance = SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS (This);
|
||||||
|
|
||||||
@ -945,6 +960,24 @@ SnpNt32Transmit (
|
|||||||
|
|
||||||
if (ReturnValue < 0) {
|
if (ReturnValue < 0) {
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
|
} else {
|
||||||
|
if ((GlobalData->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT) >= SNP_MAX_TX_BUFFER_NUM) {
|
||||||
|
return EFI_NOT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GlobalData->RecycledTxBufCount < GlobalData->MaxRecycledTxBuf) {
|
||||||
|
GlobalData->RecycledTxBuf[GlobalData->RecycledTxBufCount] = (UINT64) Buffer;
|
||||||
|
GlobalData->RecycledTxBufCount ++;
|
||||||
|
} else {
|
||||||
|
Tmp = AllocatePool (sizeof (UINT64) * (GlobalData->MaxRecycledTxBuf + SNP_TX_BUFFER_INCREASEMENT));
|
||||||
|
if (Tmp == NULL) {
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
CopyMem (Tmp, GlobalData->RecycledTxBuf, sizeof (UINT64) * GlobalData->RecycledTxBufCount);
|
||||||
|
FreePool (GlobalData->RecycledTxBuf);
|
||||||
|
GlobalData->RecycledTxBuf = Tmp;
|
||||||
|
GlobalData->MaxRecycledTxBuf += SNP_TX_BUFFER_INCREASEMENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -1083,6 +1116,11 @@ SnpNt32InitializeGlobalData (
|
|||||||
InitializeListHead (&This->InstanceList);
|
InitializeListHead (&This->InstanceList);
|
||||||
EfiInitializeLock (&This->Lock, TPL_CALLBACK);
|
EfiInitializeLock (&This->Lock, TPL_CALLBACK);
|
||||||
|
|
||||||
|
This->RecycledTxBuf = AllocatePool (sizeof (UINT64) * This->MaxRecycledTxBuf);
|
||||||
|
if (This->RecycledTxBuf == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the WinNT thunk
|
// Get the WinNT thunk
|
||||||
//
|
//
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
|
|
||||||
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -58,6 +58,12 @@ typedef struct _NT_NET_INTERFACE_INFO {
|
|||||||
#define MAX_INTERFACE_INFO_NUMBER 16
|
#define MAX_INTERFACE_INFO_NUMBER 16
|
||||||
#define MAX_FILE_NAME_LENGTH 280
|
#define MAX_FILE_NAME_LENGTH 280
|
||||||
|
|
||||||
|
#define SNP_MAX_TX_BUFFER_NUM 65536
|
||||||
|
#define SNP_TX_BUFFER_INCREASEMENT 32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Functions in Net Library
|
// Functions in Net Library
|
||||||
//
|
//
|
||||||
@ -154,6 +160,20 @@ struct _SNPNT32_GLOBAL_DATA {
|
|||||||
|
|
||||||
EFI_LOCK Lock;
|
EFI_LOCK Lock;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Array of the recycled transmit buffer address.
|
||||||
|
//
|
||||||
|
UINT64 *RecycledTxBuf;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Current number of recycled buffer pointers in RecycledTxBuf.
|
||||||
|
//
|
||||||
|
UINT32 RecycledTxBufCount;
|
||||||
|
|
||||||
|
// The maximum number of recycled buffer pointers in RecycledTxBuf.
|
||||||
|
//
|
||||||
|
UINT32 MaxRecycledTxBuf;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private functions
|
// Private functions
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user