XHCI: Add assert that the context is really page-aligned if needed.

_OffsetContextAddr assumes it will be in order to do some rather
annoying pointer arithmetic, but that was never actually asserted.
This commit is contained in:
Augustin Cavalier 2021-09-15 19:02:50 -04:00
parent 2296578c93
commit 1da090bc56

View File

@ -1384,6 +1384,11 @@ XHCI::AllocateDevice(Hub *parent, int8 hubAddress, uint8 hubPort,
TRACE_ERROR("unable to create a input context area\n");
return NULL;
}
if (fContextSizeShift == 1) {
// 64-byte contexts have to be page-aligned in order for
// _OffsetContextAddr to function properly.
ASSERT((((addr_t)device->input_ctx) % B_PAGE_SIZE) == 0);
}
memset(device->input_ctx, 0, sizeof(*device->input_ctx) << fContextSizeShift);
_WriteContext(&device->input_ctx->input.dropFlags, 0);