mirror of
https://github.com/reactos/reactos.git
synced 2025-05-08 19:27:00 +00:00
[HDAUDBUS] Wait until the correct number of responses was received. CORE-15465
We previously only gave the device a hard-coded amount of time to respond, which could lead to interpreting the contents of uninitialized memory as a response. This would lead to an unreasonably large number of audio function groups being detected. A KSEMAPHORE mirrors what Haiku uses here, though it may not be the optimal synchronization primitive for this case under Windows.
This commit is contained in:
parent
8530ae9950
commit
1001e6089f
2 changed files with 12 additions and 5 deletions
|
@ -129,6 +129,7 @@ HDA_DpcForIsr(
|
||||||
/* store response */
|
/* store response */
|
||||||
Codec->Responses[Codec->ResponseCount] = Response;
|
Codec->Responses[Codec->ResponseCount] = Response;
|
||||||
Codec->ResponseCount++;
|
Codec->ResponseCount++;
|
||||||
|
KeReleaseSemaphore(&Codec->ResponseSemaphore, IO_NO_INCREMENT, 1, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,17 +168,21 @@ HDA_SendVerbs(
|
||||||
|
|
||||||
DeviceExtension->CorbBase[WritePosition] = Verbs[Sent++];
|
DeviceExtension->CorbBase[WritePosition] = Verbs[Sent++];
|
||||||
DeviceExtension->CorbWritePos = WritePosition;
|
DeviceExtension->CorbWritePos = WritePosition;
|
||||||
|
|
||||||
// FIXME HACK
|
|
||||||
// do proper synchronization
|
|
||||||
WRITE_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_CORB_WRITE_POS), DeviceExtension->CorbWritePos);
|
|
||||||
KeStallExecutionProcessor(30);
|
|
||||||
Queued++;
|
Queued++;
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_CORB_WRITE_POS), DeviceExtension->CorbWritePos);
|
WRITE_REGISTER_USHORT((PUSHORT)(DeviceExtension->RegBase + HDAC_CORB_WRITE_POS), DeviceExtension->CorbWritePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (Queued--)
|
||||||
|
{
|
||||||
|
KeWaitForSingleObject(&Codec->ResponseSemaphore,
|
||||||
|
Executive,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (Responses != NULL) {
|
if (Responses != NULL) {
|
||||||
memcpy(Responses, Codec->Responses, Codec->ResponseCount * sizeof(ULONG));
|
memcpy(Responses, Codec->Responses, Codec->ResponseCount * sizeof(ULONG));
|
||||||
}
|
}
|
||||||
|
@ -207,6 +212,7 @@ HDA_InitCodec(
|
||||||
|
|
||||||
/* init codec */
|
/* init codec */
|
||||||
Entry->Addr = codecAddress;
|
Entry->Addr = codecAddress;
|
||||||
|
KeInitializeSemaphore(&Entry->ResponseSemaphore, 0, MAX_CODEC_RESPONSES);
|
||||||
|
|
||||||
/* get device extension */
|
/* get device extension */
|
||||||
DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct
|
||||||
|
|
||||||
ULONG Responses[MAX_CODEC_RESPONSES];
|
ULONG Responses[MAX_CODEC_RESPONSES];
|
||||||
ULONG ResponseCount;
|
ULONG ResponseCount;
|
||||||
|
KSEMAPHORE ResponseSemaphore;
|
||||||
|
|
||||||
PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS];
|
PHDA_CODEC_AUDIO_GROUP AudioGroups[HDA_MAX_AUDIO_GROUPS];
|
||||||
ULONG AudioGroupCount;
|
ULONG AudioGroupCount;
|
||||||
|
|
Loading…
Reference in a new issue