From patchwork Wed Dec 16 17:46:15 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 41280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BF309B6F2B for ; Thu, 17 Dec 2009 04:50:27 +1100 (EST) Received: from localhost ([127.0.0.1]:49717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKy13-0008AK-3b for incoming@patchwork.ozlabs.org; Wed, 16 Dec 2009 12:50:25 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKxxC-0006Rg-M5 for qemu-devel@nongnu.org; Wed, 16 Dec 2009 12:46:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKxx7-0006Lv-17 for qemu-devel@nongnu.org; Wed, 16 Dec 2009 12:46:25 -0500 Received: from [199.232.76.173] (port=52488 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKxx6-0006Li-T7 for qemu-devel@nongnu.org; Wed, 16 Dec 2009 12:46:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64472) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKxx6-0005i9-AG for qemu-devel@nongnu.org; Wed, 16 Dec 2009 12:46:20 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBGHkJDU006849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Dec 2009 12:46:19 -0500 Received: from zweiblum.home.kraxel.org (vpn2-9-244.ams2.redhat.com [10.36.9.244]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBGHkHIc024488; Wed, 16 Dec 2009 12:46:18 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 5500A70FCA; Wed, 16 Dec 2009 18:46:16 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 16 Dec 2009 18:46:15 +0100 Message-Id: <1260985576-10736-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1260985576-10736-1-git-send-email-kraxel@redhat.com> References: <1260985576-10736-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 2/3] fw_cfg: file xfer api X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Gerd Hoffmann --- hw/fw_cfg.c | 22 ++++++++++++++++++++++ hw/fw_cfg.h | 22 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletions(-) diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 2e3662d..1dd7d6a 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -47,6 +47,7 @@ typedef struct _FWCfgEntry { struct _FWCfgState { FWCfgEntry entries[2][FW_CFG_MAX_ENTRY]; + FWCfgFiles *files; uint16_t cur_entry; uint32_t cur_offset; }; @@ -273,6 +274,27 @@ int fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback, return 1; } +int fw_cfg_add_file(FWCfgState *s, uint8_t type, uint8_t *data, uint32_t len) +{ + if (!s->files) { + int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS; + s->files = qemu_mallocz(dsize); + fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize); + } + if (s->files->count == FW_CFG_FILE_SLOTS) { + fprintf(stderr, "fw_cfg: out of file slots\n"); + return 0; + } + + fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + s->files->count, data, len); + s->files->f[s->files->count].type = type; + s->files->f[s->files->count].size = len; + s->files->f[s->files->count].select = FW_CFG_FILE_FIRST + s->files->count; + s->files->count++; + + return 1; +} + FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, target_phys_addr_t ctl_addr, target_phys_addr_t data_addr) { diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h index b06665e..460d64d 100644 --- a/hw/fw_cfg.h +++ b/hw/fw_cfg.h @@ -26,7 +26,11 @@ #define FW_CFG_SETUP_ADDR 0x16 #define FW_CFG_SETUP_SIZE 0x17 #define FW_CFG_SETUP_DATA 0x18 -#define FW_CFG_MAX_ENTRY 0x19 +#define FW_CFG_FILE_DIR 0x19 + +#define FW_CFG_FILE_FIRST 0x20 +#define FW_CFG_FILE_SLOTS 0x10 +#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS) #define FW_CFG_WRITE_CHANNEL 0x4000 #define FW_CFG_ARCH_LOCAL 0x8000 @@ -34,6 +38,22 @@ #define FW_CFG_INVALID 0xffff +#define FW_CFG_FILE_TYPE_UNKNOWN 0 +#define FW_CFG_FILE_TYPE_VGABIOS 1 +#define FW_CFG_FILE_TYPE_OPTIONROM 2 + +typedef struct FWCfgFile { + uint32_t size; /* file size */ + uint16_t select; /* write this to 0x510 to read it */ + uint8_t type; /* vga, option, other? */ + uint8_t reserved; +} FWCfgFile; + +typedef struct FWCfgFiles { + uint32_t count; + FWCfgFile f[]; +} FWCfgFiles; + #ifndef NO_QEMU_PROTOS typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);