From nobody Sat May 10 08:05:28 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1529067530549656.0596377686102; Fri, 15 Jun 2018 05:58:50 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coreboot.org) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1fToLs-0001KA-1N; Fri, 15 Jun 2018 15:01:16 +0200 Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1fToLa-0001EF-Pf for seabios@seabios.org; Fri, 15 Jun 2018 15:01:12 +0200 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8F5F402312B for ; Fri, 15 Jun 2018 12:57:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-109.ams2.redhat.com [10.36.116.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7074E2024CA2; Fri, 15 Jun 2018 12:57:40 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8670524EF10; Fri, 15 Jun 2018 14:57:39 +0200 (CEST) From: Gerd Hoffmann To: seabios@seabios.org Date: Fri, 15 Jun 2018 14:57:36 +0200 Message-Id: <20180615125737.10794-3-kraxel@redhat.com> In-Reply-To: <20180615125737.10794-1-kraxel@redhat.com> References: <20180615125737.10794-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 12:57:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 15 Jun 2018 12:57:40 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-Spam-Score: -6.0 (------) Subject: [SeaBIOS] [PATCH v2 2/3] vgasrc: add allocate_pmm() X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Factor out pmm allocation function from stack allocator. Signed-off-by: Gerd Hoffmann --- vgasrc/vgautil.h | 1 + vgasrc/vgainit.c | 48 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/vgasrc/vgautil.h b/vgasrc/vgautil.h index d93da76b4a..0f2dba4c2a 100644 --- a/vgasrc/vgautil.h +++ b/vgasrc/vgautil.h @@ -92,6 +92,7 @@ extern u8 vgafont16alt[]; // vgainit.c extern int VgaBDF; extern int HaveRunInit; +u32 allocate_pmm(u32 size, int highmem, int aligned); =20 // vgaversion.c extern const char VERSION[], BUILDINFO[]; diff --git a/vgasrc/vgainit.c b/vgasrc/vgainit.c index 26570dc8fa..cd9108d2de 100644 --- a/vgasrc/vgainit.c +++ b/vgasrc/vgainit.c @@ -42,13 +42,9 @@ struct pci_data rom_pci_data VAR16 VISIBLE16 =3D { * PMM call and extra stack setup ****************************************************************/ =20 -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=3D0; pmmscan < BUILD_BIOS_SIZE; pmmscan+=3D16) { struct pmmheader *pmm =3D (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 =3D 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 %04= x:%04x\n" + , size, highmem ? "highmem" : "lowmem" , entry.seg, entry.offset); u16 res1, res2; + u16 flags =3D 8 | + ( highmem ? 2 : 1 )| + ( aligned ? 4 : 0 ); + size >>=3D 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), "=3Da" (res1), "=3Dd" (res2) : : "cc", = "memory"); + : "+r" (entry.segoff), "+r" (size), "+r" (flags), + "=3Da" (res1), "=3Dd" (res2) : : "cc", "memory"); u32 res =3D res1 | (res2 << 16); if (!res || res =3D=3D 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 =3D 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; } =20 =20 --=20 2.9.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios