From nobody Sat May 10 08:26:54 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.zoho.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; Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1487621735681592.8738499647561; Mon, 20 Feb 2017 12:15:35 -0800 (PST) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1cfuMj-00087h-WA; Mon, 20 Feb 2017 21:15:22 +0100 Received: from mail-ot0-f176.google.com ([74.125.82.176]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1cfuMV-00082i-1g for seabios@seabios.org; Mon, 20 Feb 2017 21:15:20 +0100 Received: by mail-ot0-f176.google.com with SMTP id x10so36002441otb.1 for ; Mon, 20 Feb 2017 12:15:06 -0800 (PST) Received: from Arrow.corp.skyportsystems.com (76-236-31-201.lightspeed.sntcca.sbcglobal.net. [76.236.31.201]) by smtp.gmail.com with ESMTPSA id b138sm2626246oih.14.2017.02.20.12.15.03 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Feb 2017 12:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skyportsystems.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=8MJCo6c0kslv5GoW7VDsdZExqtLiNGjd7dGxXa+4jIU=; b=0VgJVuz1b/I6dxH6YG9HdsKtOhkBGe1+6cyasPS5mVoWfm+p0CNmItDcA9f2Kl6+Pe ktotsOMipWbzmIq3ls9Ax6ecj1C4wi7OygB8pC4Bm8ICVfqupY++3yfZtv9VZ5Lli05e fAlfrUXzwq+B42BJlAQedVO6D0r2F35x3PT+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=8MJCo6c0kslv5GoW7VDsdZExqtLiNGjd7dGxXa+4jIU=; b=TazfmQY4zuQbdHzXWZqgLaSWt6h/lUQ8IgzTkLWCcEfyobOOp+EfKQzVhgl17fLXmn 3kGBP4XMI7xccmWbF5JYf/IgKw3LT+XHsXhFqUCiYkrm8CCPjTWcZssUAGBfQHJHcbbs ASf/GY05V1JaOsdVN+efRglDRTPVvswB8jWcniu/8TRNQuEeGQvCLLsHjucNiUGgfQCI mNbmZPmqYiD6kaCH71PvqxF4mh524BANApbrjpHQSEpXHc6ZYk0DDH+rcPyc4H8gIqxC XFDPwUBqhp5EN7nL3ybGOim6R9FbuL3EYcEQowuRSTcwwybLghdhUdg0U1JPgtDlmgnS 0q2w== X-Gm-Message-State: AMke39kvGVnwFfdiaT8SoHYQguA2kQvro6c5xcXVw6+g+h7Jq2lTPXuAznJQZANrN6Nm6hdC X-Received: by 10.157.27.233 with SMTP id v38mr4211762otv.200.1487621704821; Mon, 20 Feb 2017 12:15:04 -0800 (PST) From: ben@skyportsystems.com To: seabios@seabios.org Date: Mon, 20 Feb 2017 12:14:56 -0800 Message-Id: <453f0b8e11cfd2a3f3bc48c34a5d4a4d89eb479e.1487621478.git.ben@skyportsystems.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: References: In-Reply-To: References: X-Spam-Score: -1.8 (-) Subject: [SeaBIOS] [PATCH v6 4/5] QEMU fw_cfg: Add functions for accessing files by key X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, mst@redhat.com 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" From: Ben Warren Due to memory contraints, when resuming from S3 the fw_cfg "files" API isn't available. This adds a simple API to get a file 'key', and to write to the file using the key as a reference. Signed-off-by: Ben Warren Reviewed-by: Laszlo Ersek --- src/fw/paravirt.c | 32 ++++++++++++++++++++++++++------ src/fw/paravirt.h | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 4618647..225b08b 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -329,6 +329,17 @@ qemu_cfg_read_file(struct romfile_s *file, void *dst, = u32 maxlen) return file->size; } =20 +// Bare-bones function for writing a file knowing only its unique +// identifying key (select) +int +qemu_cfg_write_file_simple(void *src, u16 key, u32 offset, u32 len) +{ + qemu_cfg_select(key); + qemu_cfg_skip(offset); + qemu_cfg_write(src, len); + return len; +} + int qemu_cfg_write_file(void *src, struct romfile_s *file, u32 offset, u32 len) { @@ -339,15 +350,12 @@ qemu_cfg_write_file(void *src, struct romfile_s *file= , u32 offset, u32 len) warn_internalerror(); return -1; } - struct qemu_romfile_s *qfile; - qfile =3D container_of(file, struct qemu_romfile_s, file); + u16 key =3D qemu_get_romfile_key(file); if (offset =3D=3D 0) { /* Do it in one transfer */ - qemu_cfg_write_entry(src, qfile->select, len); + qemu_cfg_write_entry(src, key, len); } else { - qemu_cfg_select(qfile->select); - qemu_cfg_skip(offset); - qemu_cfg_write(src, len); + qemu_cfg_write_file_simple(src, key, offset, len); } return len; } @@ -370,6 +378,18 @@ qemu_romfile_add(char *name, int select, int skip, int= size) } =20 u16 +qemu_get_romfile_key(struct romfile_s *file) +{ + struct qemu_romfile_s *qfile; + if (file->copy !=3D qemu_cfg_read_file) { + warn_internalerror(); + return 0; + } + qfile =3D container_of(file, struct qemu_romfile_s, file); + return qfile->select; +} + +u16 qemu_get_present_cpus_count(void) { u16 smp_count =3D 0; diff --git a/src/fw/paravirt.h b/src/fw/paravirt.h index fb220d8..16f3d9a 100644 --- a/src/fw/paravirt.h +++ b/src/fw/paravirt.h @@ -56,5 +56,7 @@ void qemu_cfg_init(void); =20 u16 qemu_get_present_cpus_count(void); int qemu_cfg_write_file(void *src, struct romfile_s *file, u32 offset, u32= len); +int qemu_cfg_write_file_simple(void *src, u16 key, u32 offset, u32 len); +u16 qemu_get_romfile_key(struct romfile_s *file); =20 #endif --=20 2.7.4 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://www.coreboot.org/mailman/listinfo/seabios