0021-Fix-compilation-on-x86_64.patch 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From 8d46c537d4df8c785af4b85644d311ba53af5964 Mon Sep 17 00:00:00 2001
  2. From: Patrick Rudolph <patrick.rudolph@9elements.com>
  3. Date: Wed, 24 Feb 2021 08:25:41 +0100
  4. Subject: [PATCH 21/22] Fix compilation on x86_64
  5. Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
  6. ---
  7. grub-core/bus/usb/xhci.c | 24 ++++++++++++++++--------
  8. 1 file changed, 16 insertions(+), 8 deletions(-)
  9. diff --git a/grub-core/bus/usb/xhci.c b/grub-core/bus/usb/xhci.c
  10. index f4591ffb5..3495bb919 100644
  11. --- a/grub-core/bus/usb/xhci.c
  12. +++ b/grub-core/bus/usb/xhci.c
  13. @@ -184,7 +184,7 @@ enum
  14. * then we can get it from a trb pointer (provided by evt ring).
  15. */
  16. #define XHCI_RING(_trb) \
  17. - ((struct grub_xhci_ring*)((grub_uint32_t)(_trb) & ~(GRUB_XHCI_RING_SIZE-1)))
  18. + ((struct grub_xhci_ring*)((grub_addr_t)(_trb) & ~(GRUB_XHCI_RING_SIZE-1)))
  19. /* slot context */
  20. struct grub_xhci_slotctx {
  21. @@ -495,6 +495,14 @@ grub_xhci_read8(volatile void *addr) {
  22. return (*((volatile grub_uint32_t *)addr));
  23. }
  24. +static inline void *
  25. +grub_xhci_read_etrb_ptr(volatile struct grub_xhci_trb *trb) {
  26. + grub_uint64_t tmp;
  27. + tmp = (grub_uint64_t)grub_xhci_read32(&trb->ptr_low);
  28. + tmp |= ((grub_uint64_t)grub_xhci_read32(&trb->ptr_high)) << 32;
  29. + return (void *)(grub_addr_t)tmp;
  30. +}
  31. +
  32. static inline grub_uint32_t
  33. grub_xhci_port_read (struct grub_xhci *x, grub_uint32_t port)
  34. {
  35. @@ -664,7 +672,7 @@ static void xhci_process_events(struct grub_xhci *x)
  36. case ER_TRANSFER:
  37. case ER_COMMAND_COMPLETE:
  38. {
  39. - struct grub_xhci_trb *rtrb = (void*)grub_xhci_read32(&etrb->ptr_low);
  40. + struct grub_xhci_trb *rtrb = grub_xhci_read_etrb_ptr(etrb);
  41. struct grub_xhci_ring *ring = XHCI_RING(rtrb);
  42. volatile struct grub_xhci_trb *evt = &ring->evt;
  43. grub_uint32_t eidx = rtrb - ring->ring + 1;
  44. @@ -697,9 +705,9 @@ static void xhci_process_events(struct grub_xhci *x)
  45. }
  46. grub_xhci_write32(&evts->nidx, nidx);
  47. volatile struct grub_xhci_ir *ir = x->ir;
  48. - grub_uint32_t erdp = (grub_uint32_t)(evts->ring + nidx);
  49. - grub_xhci_write32(&ir->erdp_low, erdp);
  50. - grub_xhci_write32(&ir->erdp_high, 0);
  51. + grub_uint64_t erdp = (grub_addr_t)(void *)(&evts->ring[nidx]);
  52. + grub_xhci_write32(&ir->erdp_low, erdp & 0xffffffff);
  53. + grub_xhci_write32(&ir->erdp_high, erdp >> 32);
  54. }
  55. }
  56. @@ -800,7 +808,7 @@ static void xhci_trb_queue(volatile struct grub_xhci_ring *ring,
  57. grub_uint32_t xferlen, grub_uint32_t flags)
  58. {
  59. grub_dprintf("xhci", "%s: ring %p data %llx len %d flags 0x%x remain 0x%x\n", __func__,
  60. - ring, data_or_addr, xferlen & 0x1ffff, flags, xferlen >> 17);
  61. + ring, (unsigned long long)data_or_addr, xferlen & 0x1ffff, flags, xferlen >> 17);
  62. if (xhci_ring_full(ring))
  63. {
  64. @@ -1907,7 +1915,7 @@ grub_xhci_setup_transfer (grub_usb_controller_t dev,
  65. if (transfer->type == GRUB_USB_TRANSACTION_TYPE_CONTROL)
  66. {
  67. volatile struct grub_usb_packet_setup *setupdata;
  68. - setupdata = (void *)transfer->transactions[0].data;
  69. + setupdata = (void *)(grub_addr_t)transfer->transactions[0].data;
  70. grub_dprintf("xhci", "%s: CONTROLL TRANS req %d\n", __func__, setupdata->request);
  71. grub_dprintf("xhci", "%s: CONTROLL TRANS length %d\n", __func__, setupdata->length);
  72. @@ -1974,7 +1982,7 @@ grub_xhci_setup_transfer (grub_usb_controller_t dev,
  73. /* Assume the ring has enough free space for all TRBs */
  74. if (flags & TRB_TR_IDT && tr->size <= (int)sizeof(inline_data))
  75. {
  76. - grub_memcpy(&inline_data, (void *)tr->data, tr->size);
  77. + grub_memcpy(&inline_data, (void *)(grub_addr_t)tr->data, tr->size);
  78. xhci_trb_queue(reqs, inline_data, tr->size, flags);
  79. }
  80. else
  81. --
  82. 2.39.2