Index: uspace/drv/bus/usb/xhci/debug.c
===================================================================
--- uspace/drv/bus/usb/xhci/debug.c	(revision c6f82e543978d3fafa47bd89b2e23a3d0a86cf50)
+++ uspace/drv/bus/usb/xhci/debug.c	(revision 7ec7b7ea64f1e1a3249fed297c953a7cb4fe5479)
@@ -383,22 +383,27 @@
 }
 
-void xhci_dump_input_ctx(const struct xhci_input_ctx *ctx)
-{
+void xhci_dump_input_ctx(const xhci_hc_t * hc, const struct xhci_input_ctx *ictx)
+{
+	xhci_device_ctx_t *device_ctx = XHCI_GET_DEVICE_CTX(ictx, hc);
+	xhci_slot_ctx_t *slot_ctx = XHCI_GET_SLOT_CTX(device_ctx, hc);
+	xhci_input_ctrl_ctx_t *ctrl_ctx = XHCI_GET_CTRL_CTX(ictx, hc);
+
 	usb_log_debug("Input control context:");
-	usb_log_debug("\tDrop:\t0x%08x", xhci2host(32, ctx->ctrl_ctx.data[0]));
-	usb_log_debug("\tAdd:\t0x%08x", xhci2host(32, ctx->ctrl_ctx.data[1]));
-
-	usb_log_debug("\tConfig:\t0x%02x", XHCI_INPUT_CTRL_CTX_CONFIG_VALUE(ctx->ctrl_ctx));
-	usb_log_debug("\tIface:\t0x%02x", XHCI_INPUT_CTRL_CTX_IFACE_NUMBER(ctx->ctrl_ctx));
-	usb_log_debug("\tAlternate:\t0x%02x", XHCI_INPUT_CTRL_CTX_ALTER_SETTING(ctx->ctrl_ctx));
+	usb_log_debug("\tDrop:\t0x%08x", xhci2host(32, ctrl_ctx->data[0]));
+	usb_log_debug("\tAdd:\t0x%08x", xhci2host(32, ctrl_ctx->data[1]));
+
+	usb_log_debug("\tConfig:\t0x%02x", XHCI_INPUT_CTRL_CTX_CONFIG_VALUE(*ctrl_ctx));
+	usb_log_debug("\tIface:\t0x%02x", XHCI_INPUT_CTRL_CTX_IFACE_NUMBER(*ctrl_ctx));
+	usb_log_debug("\tAlternate:\t0x%02x", XHCI_INPUT_CTRL_CTX_ALTER_SETTING(*ctrl_ctx));
 
 	usb_log_debug("Slot context:");
-	xhci_dump_slot_ctx(&ctx->slot_ctx);
+	xhci_dump_slot_ctx(slot_ctx);
 
 	for (uint8_t dci = 1; dci <= XHCI_EP_COUNT; dci++)
-		if (XHCI_INPUT_CTRL_CTX_DROP(ctx->ctrl_ctx, dci)
-		    || XHCI_INPUT_CTRL_CTX_ADD(ctx->ctrl_ctx, dci)) {
+		if (XHCI_INPUT_CTRL_CTX_DROP(*ctrl_ctx, dci)
+		    || XHCI_INPUT_CTRL_CTX_ADD(*ctrl_ctx, dci)) {
 			usb_log_debug("Endpoint context DCI %u:", dci);
-			xhci_dump_endpoint_ctx(&ctx->endpoint_ctx[dci - 1]);
+			xhci_ep_ctx_t *ep_ctx = XHCI_GET_EP_CTX(device_ctx, hc, dci - 1);
+			xhci_dump_endpoint_ctx(ep_ctx);
 		}
 }
Index: uspace/drv/bus/usb/xhci/debug.h
===================================================================
--- uspace/drv/bus/usb/xhci/debug.h	(revision c6f82e543978d3fafa47bd89b2e23a3d0a86cf50)
+++ uspace/drv/bus/usb/xhci/debug.h	(revision 7ec7b7ea64f1e1a3249fed297c953a7cb4fe5479)
@@ -37,4 +37,6 @@
 #define XHCI_DEBUG_H
 
+#include "hc.h"
+
 /**
  * As the debug header is likely to be included in every file, avoid including
@@ -63,5 +65,5 @@
 void xhci_dump_slot_ctx(const struct xhci_slot_ctx *);
 void xhci_dump_endpoint_ctx(const struct xhci_endpoint_ctx *);
-void xhci_dump_input_ctx(const struct xhci_input_ctx *);
+void xhci_dump_input_ctx(const xhci_hc_t *, const struct xhci_input_ctx *);
 
 #endif
Index: uspace/drv/bus/usb/xhci/endpoint.c
===================================================================
--- uspace/drv/bus/usb/xhci/endpoint.c	(revision c6f82e543978d3fafa47bd89b2e23a3d0a86cf50)
+++ uspace/drv/bus/usb/xhci/endpoint.c	(revision 7ec7b7ea64f1e1a3249fed297c953a7cb4fe5479)
@@ -326,5 +326,6 @@
 	unsigned idx = xhci_endpoint_index(ep);
 	xhci_device_ctx_t *ctx = dev->dev_ctx.virt;
-	xhci_ep_ctx_t *ep_ctx = &ctx->endpoint_ctx[idx];
+	const xhci_hc_t * hc = bus_to_hc(dev->base.bus);
+	xhci_ep_ctx_t *ep_ctx = XHCI_GET_EP_CTX(ctx, hc, idx);
 
 	return XHCI_EP_STATE(*ep_ctx);
Index: uspace/drv/bus/usb/xhci/hc.c
===================================================================
--- uspace/drv/bus/usb/xhci/hc.c	(revision c6f82e543978d3fafa47bd89b2e23a3d0a86cf50)
+++ uspace/drv/bus/usb/xhci/hc.c	(revision 7ec7b7ea64f1e1a3249fed297c953a7cb4fe5479)
@@ -223,4 +223,5 @@
 
 	hc->ac64 = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_AC64);
+	hc->csz = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_CSZ);
 	hc->max_slots = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_MAX_SLOTS);
 
@@ -723,7 +724,7 @@
 
 	/* Prepare memory for the context */
-	if ((err = dma_buffer_alloc(&dev->dev_ctx, sizeof(xhci_device_ctx_t))))
+	if ((err = dma_buffer_alloc(&dev->dev_ctx, XHCI_DEVICE_CTX_SIZE(hc))))
 		return err;
-	memset(dev->dev_ctx.virt, 0, sizeof(xhci_device_ctx_t));
+	memset(dev->dev_ctx.virt, 0, XHCI_DEVICE_CTX_SIZE(hc));
 
 	/* Get the slot number */
@@ -807,14 +808,16 @@
 static int create_configure_ep_input_ctx(xhci_device_t *dev, dma_buffer_t *dma_buf)
 {
-	const int err = dma_buffer_alloc(dma_buf, sizeof(xhci_input_ctx_t));
+	const xhci_hc_t * hc = bus_to_hc(dev->base.bus);
+	const int err = dma_buffer_alloc(dma_buf, XHCI_INPUT_CTX_SIZE(hc));
 	if (err)
 		return err;
 
 	xhci_input_ctx_t *ictx = dma_buf->virt;
-	memset(ictx, 0, sizeof(xhci_input_ctx_t));
+	memset(ictx, 0, XHCI_INPUT_CTX_SIZE(hc));
 
 	// Quoting sec. 4.6.5 and 4.6.6: A1, D0, D1 are down (already zeroed), A0 is up.
-	XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, 0);
-	xhci_setup_slot_context(dev, &ictx->slot_ctx);
+	XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), 0);
+	xhci_slot_ctx_t *slot_ctx = XHCI_GET_SLOT_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc);
+	xhci_setup_slot_context(dev, slot_ctx);
 
 	return EOK;
@@ -846,9 +849,9 @@
 
 	/* Copy endpoint 0 context and set A1 flag. */
-	XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, 1);
-	xhci_setup_endpoint_context(ep0, &ictx->endpoint_ctx[0]);
-
+	XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), 1);
+	xhci_ep_ctx_t *ep_ctx = XHCI_GET_EP_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc, 0);
+	xhci_setup_endpoint_context(ep0, ep_ctx);
 	/* Address device needs Ctx entries set to 1 only */
-	xhci_slot_ctx_t *slot_ctx = &ictx->slot_ctx;
+	xhci_slot_ctx_t *slot_ctx = XHCI_GET_SLOT_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc);
 	XHCI_SLOT_CTX_ENTRIES_SET(*slot_ctx, 1);
 
@@ -857,6 +860,6 @@
 		return err;
 
-	xhci_device_ctx_t *dev_ctx = dev->dev_ctx.virt;
-	dev->base.address = XHCI_SLOT_DEVICE_ADDRESS(dev_ctx->slot_ctx);
+	xhci_device_ctx_t *device_ctx = dev->dev_ctx.virt;
+	dev->base.address = XHCI_SLOT_DEVICE_ADDRESS(*XHCI_GET_SLOT_CTX(device_ctx, hc));
 	usb_log_debug2("Obtained USB address: %d.", dev->base.address);
 
@@ -911,8 +914,11 @@
 
 	xhci_input_ctx_t *ictx = ictx_dma_buf.virt;
-	XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, ep_idx + 1); /* Preceded by slot ctx */
-	memcpy(&ictx->endpoint_ctx[ep_idx], ep_ctx, sizeof(xhci_ep_ctx_t));
 
 	xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
+	XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), ep_idx + 1); /* Preceded by slot ctx */
+
+	xhci_ep_ctx_t *_ep_ctx = XHCI_GET_EP_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc, ep_idx);
+	memcpy(_ep_ctx, ep_ctx, XHCI_ONE_CTX_SIZE(hc));
+
 	return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf);
 }
@@ -932,8 +938,8 @@
 		return err;
 
+	xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
 	xhci_input_ctx_t *ictx = ictx_dma_buf.virt;
-	XHCI_INPUT_CTRL_CTX_DROP_SET(ictx->ctrl_ctx, ep_idx + 1); /* Preceded by slot ctx */
-
-	xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
+	XHCI_INPUT_CTRL_CTX_DROP_SET(*XHCI_GET_CTRL_CTX(ictx, hc), ep_idx + 1); /* Preceded by slot ctx */
+
 	return xhci_cmd_sync_inline(hc, CONFIGURE_ENDPOINT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf);
 }
@@ -950,15 +956,17 @@
 {
 	dma_buffer_t ictx_dma_buf;
-	const int err = dma_buffer_alloc(&ictx_dma_buf, sizeof(xhci_input_ctx_t));
+	xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
+
+	const int err = dma_buffer_alloc(&ictx_dma_buf, XHCI_INPUT_CTX_SIZE(hc));
 	if (err)
 		return err;
 
 	xhci_input_ctx_t *ictx = ictx_dma_buf.virt;
-	memset(ictx, 0, sizeof(xhci_input_ctx_t));
-
-	XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, ep_idx + 1);
-	memcpy(&ictx->endpoint_ctx[ep_idx], ep_ctx, sizeof(xhci_ep_ctx_t));
-
-	xhci_hc_t * const hc = bus_to_hc(dev->base.bus);
+	memset(ictx, 0, XHCI_INPUT_CTX_SIZE(hc));
+
+	XHCI_INPUT_CTRL_CTX_ADD_SET(*XHCI_GET_CTRL_CTX(ictx, hc), ep_idx + 1);
+	xhci_ep_ctx_t *_ep_ctx = XHCI_GET_EP_CTX(XHCI_GET_DEVICE_CTX(ictx, hc), hc, 0);
+	memcpy(_ep_ctx, ep_ctx, sizeof(xhci_ep_ctx_t));
+
 	return xhci_cmd_sync_inline(hc, EVALUATE_CONTEXT, .slot_id = dev->slot_id, .input_ctx = ictx_dma_buf);
 }
Index: uspace/drv/bus/usb/xhci/hc.h
===================================================================
--- uspace/drv/bus/usb/xhci/hc.h	(revision c6f82e543978d3fafa47bd89b2e23a3d0a86cf50)
+++ uspace/drv/bus/usb/xhci/hc.h	(revision 7ec7b7ea64f1e1a3249fed297c953a7cb4fe5479)
@@ -96,4 +96,5 @@
 	unsigned max_slots;
 	bool ac64;
+	bool csz;
 	uint64_t wrap_time;		/** The last time when mfindex wrap happened */
 	uint64_t wrap_count;	/** Amount of mfindex wraps HC has done */
Index: uspace/drv/bus/usb/xhci/hw_struct/context.h
===================================================================
--- uspace/drv/bus/usb/xhci/hw_struct/context.h	(revision c6f82e543978d3fafa47bd89b2e23a3d0a86cf50)
+++ uspace/drv/bus/usb/xhci/hw_struct/context.h	(revision 7ec7b7ea64f1e1a3249fed297c953a7cb4fe5479)
@@ -175,10 +175,20 @@
 
 /**
+ * Handling HCs with 32 or 64-bytes context size (CSZ)
+ */
+#define XHCI_CTX_SIZE_SMALL 32
+#define XHCI_ONE_CTX_SIZE(hc) (XHCI_CTX_SIZE_SMALL << hc->csz)
+#define XHCI_SLOT_CTX_OFFSET 0
+#define XHCI_EP_ARRAY_OFFSET 1
+#define XHCI_DEVICE_CTX_SIZE(hc) ((XHCI_EP_ARRAY_OFFSET + XHCI_EP_COUNT) * XHCI_ONE_CTX_SIZE(hc))
+
+/**
  * Device context: section 6.2.1
  */
+#define XHCI_GET_SLOT_CTX(dev_ctx, hc) (xhci_slot_ctx_t *)((char*)dev_ctx + XHCI_SLOT_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc))
+#define XHCI_GET_EP_CTX(dev_ctx, hc, dci) (xhci_ep_ctx_t *)((char*)dev_ctx + (dci + XHCI_EP_ARRAY_OFFSET) * XHCI_ONE_CTX_SIZE(hc))
+
 typedef struct xhci_device_ctx {
-	xhci_slot_ctx_t slot_ctx;
-	xhci_ep_ctx_t endpoint_ctx[XHCI_EP_COUNT];
-} __attribute__((packed)) xhci_device_ctx_t;
+} xhci_device_ctx_t;
 
 /**
@@ -228,9 +238,13 @@
  * Input context: section 6.2.5
  */
+
+#define XHCI_CTRL_CTX_OFFSET 0
+#define XHCI_DEVICE_CTX_OFFSET 1
+#define XHCI_INPUT_CTX_SIZE(hc) (XHCI_DEVICE_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc) + XHCI_DEVICE_CTX_SIZE(hc))
+#define XHCI_GET_CTRL_CTX(ictx, hc) (xhci_input_ctrl_ctx_t*)((char*)ictx + XHCI_CTRL_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc))
+#define XHCI_GET_DEVICE_CTX(ictx, hc) (xhci_device_ctx_t *)((char*)ictx + XHCI_DEVICE_CTX_OFFSET * XHCI_ONE_CTX_SIZE(hc))
+
 typedef struct xhci_input_ctx {
-	xhci_input_ctrl_ctx_t ctrl_ctx;
-	xhci_slot_ctx_t slot_ctx;
-	xhci_ep_ctx_t endpoint_ctx[XHCI_EP_COUNT];
-} __attribute__((packed)) xhci_input_ctx_t;
+} xhci_input_ctx_t;
 
 /**
Index: uspace/drv/bus/usb/xhci/streams.c
===================================================================
--- uspace/drv/bus/usb/xhci/streams.c	(revision c6f82e543978d3fafa47bd89b2e23a3d0a86cf50)
+++ uspace/drv/bus/usb/xhci/streams.c	(revision 7ec7b7ea64f1e1a3249fed297c953a7cb4fe5479)
@@ -338,5 +338,5 @@
 
 	xhci_ep_ctx_t ep_ctx;
-	memset(&ep_ctx, 0, sizeof(ep_ctx));
+	memset(&ep_ctx, 0, XHCI_ONE_CTX_SIZE(hc));
 	xhci_setup_endpoint_context(xhci_ep, &ep_ctx);
 	return hc_update_endpoint(dev, xhci_endpoint_index(xhci_ep), &ep_ctx);
