The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6818ff7797c6a9ab104e5d7e91d4e422874bf50d

commit 6818ff7797c6a9ab104e5d7e91d4e422874bf50d
Author:     Ahmad Khalifa <ahmadkhalifa...@gmail.com>
AuthorDate: 2024-05-14 19:29:08 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2024-09-20 14:45:07 +0000

    loader: Fix 32-bit compatibility
    
    main.c - Fix rsdp cast.
    framebuffer.c -
            - Use temp variable instead of directly passing pointer when
              EFI_PHYSICAL_ADDRESS is expected.
              Also fix FreePages cast.
            - Mask framebuffer address given to us by UEFI.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1098
---
 stand/efi/loader/framebuffer.c | 21 +++++++++++++++------
 stand/efi/loader/main.c        |  3 ++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c
index c954a2471340..ea4131b751c8 100644
--- a/stand/efi/loader/framebuffer.c
+++ b/stand/efi/loader/framebuffer.c
@@ -149,7 +149,16 @@ efifb_from_gop(struct efi_fb *efifb, 
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *mode,
 {
        int result;
 
-       efifb->fb_addr = mode->FrameBufferBase;
+       /*
+        * The Asus EEEPC 1025C, and possibly others,
+        * require the address to be masked.
+        */
+       efifb->fb_addr =
+#ifdef __i386__
+           mode->FrameBufferBase & 0xffffffff;
+#else
+           mode->FrameBufferBase;
+#endif
        efifb->fb_size = mode->FrameBufferSize;
        efifb->fb_height = info->VerticalResolution;
        efifb->fb_width = info->HorizontalResolution;
@@ -555,6 +564,7 @@ efi_has_gop(void)
 int
 efi_find_framebuffer(teken_gfx_t *gfx_state)
 {
+       EFI_PHYSICAL_ADDRESS ptr;
        EFI_HANDLE *hlist;
        UINTN nhandles, i, hsize;
        struct efi_fb efifb;
@@ -651,16 +661,15 @@ efi_find_framebuffer(teken_gfx_t *gfx_state)
            efifb.fb_mask_blue | efifb.fb_mask_reserved);
 
        if (gfx_state->tg_shadow_fb != NULL)
-               BS->FreePages((EFI_PHYSICAL_ADDRESS)gfx_state->tg_shadow_fb,
+               BS->FreePages((uintptr_t)gfx_state->tg_shadow_fb,
                    gfx_state->tg_shadow_sz);
        gfx_state->tg_shadow_sz =
            EFI_SIZE_TO_PAGES(efifb.fb_height * efifb.fb_width *
            sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
        status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData,
-           gfx_state->tg_shadow_sz,
-           (EFI_PHYSICAL_ADDRESS *)&gfx_state->tg_shadow_fb);
-       if (status != EFI_SUCCESS)
-               gfx_state->tg_shadow_fb = NULL;
+           gfx_state->tg_shadow_sz, &ptr);
+       gfx_state->tg_shadow_fb = status == EFI_SUCCESS ?
+           (uint32_t *)(uintptr_t)ptr : NULL;
 
        return (0);
 }
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index e4d62f2e940c..69fee3128569 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -45,6 +45,7 @@
 #include <disk.h>
 #include <dev_net.h>
 #include <net.h>
+#include <inttypes.h>
 
 #include <efi.h>
 #include <efilib.h>
@@ -920,7 +921,7 @@ acpi_detect(void)
                if ((rsdp = efi_get_table(&acpi)) == NULL)
                        return;
 
-       sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
+       sprintf(buf, "0x%016"PRIxPTR, (uintptr_t)rsdp);
        setenv("acpi.rsdp", buf, 1);
        revision = rsdp->Revision;
        if (revision == 0)

Reply via email to