From patchwork Tue Sep 15 14:44:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 53677 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 8128322DE5 for ; Tue, 15 Sep 2015 14:46:13 +0000 (UTC) Received: by lagj9 with SMTP id j9sf65025546lag.0 for ; Tue, 15 Sep 2015 07:46:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=94kPaF2UpSCdmJbUdHtzIRhgwatVrjWw5o2Zo9FCcCI=; b=G8OylDkBHyE5JRedvhAIIfyVi+QpwsBq8LU6Djj0HsCfIor2FcFfpgyRN8ffaXF4X/ QFPgDs4hdih6S47e29m8gPtLqGUEaViYuEZjvlA0fThxPcyDzTnX1ii6vGnICL+6kEFP lIvYt5KM7m0S8wk7bmWqAh8A4bDoczF6c2+O72fNtUd5mqSjnMU9T0Y1OO1bnDyv3o0d 1BMjplig/Qy7VUo6zaYlGXZeoU3sBtMoqP+ESRbyL7bKTqVmYyuNo9YcNL3ilyEh5+Xg mYBDrPzqo/U0PLCzzwgh3aj1RLZi9lN1UTD0u8Z/tGdJffqfOlcQuNgaKP3QKbyR1lJR +UoA== X-Gm-Message-State: ALoCoQlUf7FYGmOWv3hVgxpZ05II4itRFQeLEivPXPc8OCLltMysVrs+DkMBVGW5U9DVh1czqpVS X-Received: by 10.194.240.230 with SMTP id wd6mr1086186wjc.0.1442328372402; Tue, 15 Sep 2015 07:46:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.138 with SMTP id s10ls725382las.25.gmail; Tue, 15 Sep 2015 07:46:12 -0700 (PDT) X-Received: by 10.152.7.37 with SMTP id g5mr21526190laa.22.1442328372226; Tue, 15 Sep 2015 07:46:12 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id od3si14085707lbb.76.2015.09.15.07.46.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 07:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbpo4 with SMTP id o4so86776512lbp.2 for ; Tue, 15 Sep 2015 07:46:12 -0700 (PDT) X-Received: by 10.112.180.230 with SMTP id dr6mr10928388lbc.72.1442328372055; Tue, 15 Sep 2015 07:46:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1848998lbq; Tue, 15 Sep 2015 07:46:10 -0700 (PDT) X-Received: by 10.50.28.5 with SMTP id x5mr6670535igg.84.1442328370792; Tue, 15 Sep 2015 07:46:10 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 67si13548367iog.210.2015.09.15.07.46.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Sep 2015 07:46:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:43463 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbrUm-0008MX-HD for patch@linaro.org; Tue, 15 Sep 2015 10:46:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbrTd-0007IT-Nk for qemu-devel@nongnu.org; Tue, 15 Sep 2015 10:44:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbrTX-00068i-IT for qemu-devel@nongnu.org; Tue, 15 Sep 2015 10:44:57 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:37083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbrTX-00068I-9a for qemu-devel@nongnu.org; Tue, 15 Sep 2015 10:44:51 -0400 Received: by wicfx3 with SMTP id fx3so30709719wic.0 for ; Tue, 15 Sep 2015 07:44:50 -0700 (PDT) X-Received: by 10.194.21.163 with SMTP id w3mr6688605wje.70.1442328290767; Tue, 15 Sep 2015 07:44:50 -0700 (PDT) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginm.net. [86.14.224.72]) by smtp.gmail.com with ESMTPSA id r9sm21390508wjz.35.2015.09.15.07.44.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Sep 2015 07:44:50 -0700 (PDT) From: Leif Lindholm To: qemu-devel@nongnu.org Date: Tue, 15 Sep 2015 15:44:41 +0100 Message-Id: <1442328281-18039-3-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1442328281-18039-1-git-send-email-leif.lindholm@linaro.org> References: <1442328281-18039-1-git-send-email-leif.lindholm@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.181 Cc: peter.maydell@linaro.org, drjones@redhat.com, shannon.zhao@linaro.org, al.stone@linaro.org Subject: [Qemu-devel] [PATCH v3 2/2] hw/arm/virt-acpi-build: Add DBG2 table X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add a DBG2 table, describing the pl011 UART. Signed-off-by: Leif Lindholm --- hw/arm/virt-acpi-build.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 9088248..763d531 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -351,6 +351,89 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) return rsdp_table; } +static int +dbg2_addresses_size(int num_addr) +{ + return num_addr * (sizeof(struct AcpiGenericAddress) + sizeof(uint32_t)); +} + +static int +dbg2_dev_length(int num_addr, const char *namepath, int oemdata_length) +{ + int size; + + size = sizeof(AcpiDebugPort2Device); + size += dbg2_addresses_size(num_addr); + size += strlen(namepath) + 1; + size += oemdata_length; + + return size; +} + +static void +build_dbg2(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) +{ + const MemMapEntry *uart_memmap = &guest_info->memmap[VIRT_UART]; + AcpiDebugPort2Header *dbg2; + AcpiDebugPort2Device *dev; + struct AcpiGenericAddress *addr; + uint32_t *addr_size; + char *data; + const char namepath[] = "."; + int address_count, oem_length, table_revision, table_size; + + address_count = 1; + oem_length = 0; + table_revision = 0; + table_size = sizeof(*dbg2) + dbg2_dev_length(address_count, namepath, + oem_length); + + dbg2 = acpi_data_push(table_data, sizeof(*dbg2)); + dbg2->devices_offset = sizeof(*dbg2); + dbg2->devices_count = 1; + + dev = acpi_data_push(table_data, sizeof(*dev)); + dev->revision = table_revision; + dev->length = cpu_to_le16(dbg2_dev_length(address_count, namepath, + oem_length)); + dev->address_count = address_count; + dev->namepath_length = cpu_to_le16(strlen(namepath)); + dev->namepath_offset = cpu_to_le16(sizeof(*dev) + + dbg2_addresses_size(address_count)); + dev->oem_data_length = cpu_to_le16(oem_length); + if (oem_length) { + dev->oem_data_offset = cpu_to_le16(dbg2_dev_length(address_count, + namepath, 0)); + } else { + dev->oem_data_offset = 0; + } + dev->port_type = cpu_to_le16(0x8000); /* Serial */ + dev->port_subtype = cpu_to_le16(0x3); /* ARM PL011 UART */ + dev->base_address_offset = cpu_to_le16(sizeof(*dev)); + dev->address_size_offset = cpu_to_le16(sizeof(*dev) + + address_count * sizeof(*addr)); + + addr = acpi_data_push(table_data, sizeof(*addr) * address_count); + addr->space_id = AML_SYSTEM_MEMORY; + addr->bit_width = 8; + addr->bit_offset = 0; + addr->access_width = 1; + addr->address = cpu_to_le64(uart_memmap->base); + + addr_size = acpi_data_push(table_data, sizeof(*addr_size) * address_count); + *addr_size = cpu_to_le32(sizeof(*addr)); + + data = acpi_data_push(table_data, strlen(namepath) + 1); + strcpy(data, namepath); + + if (oem_length) { + data = acpi_data_push(table_data, oem_length); + } + + build_header(linker, table_data, (void *)dbg2, "DBG2", table_size, + table_revision); +} + static void build_spcr(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) { @@ -577,7 +660,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) dsdt = tables_blob->len; build_dsdt(tables_blob, tables->linker, guest_info); - /* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ + /* FADT MADT GTDT MCFG DBG2 SPCR pointed to by RSDT */ acpi_add_table(table_offsets, tables_blob); build_fadt(tables_blob, tables->linker, dsdt); @@ -591,6 +674,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) build_mcfg(tables_blob, tables->linker, guest_info); acpi_add_table(table_offsets, tables_blob); + build_dbg2(tables_blob, tables->linker, guest_info); + + acpi_add_table(table_offsets, tables_blob); build_spcr(tables_blob, tables->linker, guest_info); /* RSDT is pointed to by RSDP */