]> xenbits.xensource.com Git - seabios.git/commitdiff
vgasrc: add allocate_pmm()
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 15 Jun 2018 05:55:47 +0000 (07:55 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 2 Jul 2018 14:34:21 +0000 (16:34 +0200)
Factor out pmm allocation function from stack allocator.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit e1a9579acd66fb9c393c014ed26f569f20a1a4f1)

vgasrc/vgainit.c
vgasrc/vgautil.h

index c6c8149083973b9a925ecc838b9cf3cfe702f3ca..d6a297e331a3031e9a2e8be6dac97bd17defdf0c 100644 (file)
@@ -42,13 +42,9 @@ struct pci_data rom_pci_data VAR16 VISIBLE16 = {
  * PMM call and extra stack setup
  ****************************************************************/
 
-u16 ExtraStackSeg VAR16 VISIBLE16;
-
-static void
-allocate_extra_stack(void)
+u32
+allocate_pmm(u32 size, int highmem, int aligned)
 {
-    if (!CONFIG_VGA_ALLOCATE_EXTRA_STACK)
-        return;
     u32 pmmscan;
     for (pmmscan=0; pmmscan < BUILD_BIOS_SIZE; pmmscan+=16) {
         struct pmmheader *pmm = (void*)pmmscan;
@@ -57,29 +53,49 @@ allocate_extra_stack(void)
         if (checksum_far(SEG_BIOS, pmm, GET_FARVAR(SEG_BIOS, pmm->length)))
             continue;
         struct segoff_s entry = GET_FARVAR(SEG_BIOS, pmm->entry);
-        dprintf(1, "Attempting to allocate VGA stack via pmm call to %04x:%04x\n"
+        dprintf(1, "Attempting to allocate %u bytes %s via pmm call to %04x:%04x\n"
+                , size, highmem ? "highmem" : "lowmem"
                 , entry.seg, entry.offset);
         u16 res1, res2;
+        u16 flags = 8 |
+            ( highmem ? 2 : 1 )|
+            ( aligned ? 4 : 0 );
+        size >>= 4;
         asm volatile(
             "pushl %0\n"
-            "pushw $(8|1)\n"            // Permanent low memory request
+            "pushw %2\n"                // flags
             "pushl $0xffffffff\n"       // Anonymous handle
-            "pushl $" __stringify(CONFIG_VGA_EXTRA_STACK_SIZE/16) "\n"
+            "pushl %1\n"                // size
             "pushw $0x00\n"             // PMM allocation request
             "lcallw *12(%%esp)\n"
             "addl $16, %%esp\n"
             "cli\n"
             "cld\n"
-            : "+r" (entry.segoff), "=a" (res1), "=d" (res2) : : "cc", "memory");
+            : "+r" (entry.segoff), "+r" (size), "+r" (flags),
+              "=a" (res1), "=d" (res2) : : "cc", "memory");
         u32 res = res1 | (res2 << 16);
         if (!res || res == PMM_FUNCTION_NOT_SUPPORTED)
-            return;
-        dprintf(1, "VGA stack allocated at %x\n", res);
-        SET_VGA(ExtraStackSeg, res >> 4);
-        extern void entry_10_extrastack(void);
-        SET_IVT(0x10, SEGOFF(get_global_seg(), (u32)entry_10_extrastack));
-        return;
+            return 0;
+        return res;
     }
+    return 0;
+}
+
+u16 ExtraStackSeg VAR16 VISIBLE16;
+
+static void
+allocate_extra_stack(void)
+{
+    if (!CONFIG_VGA_ALLOCATE_EXTRA_STACK)
+        return;
+    u32 res = allocate_pmm(CONFIG_VGA_EXTRA_STACK_SIZE, 0, 0);
+    if (!res)
+        return;
+    dprintf(1, "VGA stack allocated at %x\n", res);
+    SET_VGA(ExtraStackSeg, res >> 4);
+    extern void entry_10_extrastack(void);
+    SET_IVT(0x10, SEGOFF(get_global_seg(), (u32)entry_10_extrastack));
+    return;
 }
 
 
index d93da76b4a0551cd4e3ef2e3807f29432030331d..0f2dba4c2a54e7567ade262db48a22ffe0dc61a1 100644 (file)
@@ -92,6 +92,7 @@ extern u8 vgafont16alt[];
 // vgainit.c
 extern int VgaBDF;
 extern int HaveRunInit;
+u32 allocate_pmm(u32 size, int highmem, int aligned);
 
 // vgaversion.c
 extern const char VERSION[], BUILDINFO[];