From nobody Wed Nov 5 12:03:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498222242968319.3678409942962; Fri, 23 Jun 2017 05:50:42 -0700 (PDT) Received: from localhost ([::1]:35388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO2p-0003HK-Ut for importer@patchew.org; Fri, 23 Jun 2017 08:50:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO0q-0001gG-O4 for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOO0m-0004RP-DA for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39994) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dOO0m-0004P9-2H for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4D94BC6A8; Fri, 23 Jun 2017 12:48:30 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0708B6FB60; Fri, 23 Jun 2017 12:48:27 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3B36F41ABE; Fri, 23 Jun 2017 14:48:29 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E4D94BC6A8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E4D94BC6A8 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 23 Jun 2017 14:48:27 +0200 Message-Id: <20170623124829.24260-2-kraxel@redhat.com> In-Reply-To: <20170623124829.24260-1-kraxel@redhat.com> References: <20170623124829.24260-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Jun 2017 12:48:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/3] applesmc: cosmetic whitespace and indentation cleanup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gabriel L. Somlo" , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Gabriel L. Somlo" Signed-off-by: Gabriel Somlo Reviewed-by: Alexander Graf Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Phil Dennis-Jordan Message-id: 1497639316-22202-2-git-send-email-gsomlo@gmail.com Signed-off-by: Gerd Hoffmann --- hw/misc/applesmc.c | 98 ++++++++++++++++++++++++++++----------------------= ---- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c index 77fab5b9d2..6381197728 100644 --- a/hw/misc/applesmc.c +++ b/hw/misc/applesmc.c @@ -39,21 +39,24 @@ /* #define DEBUG_SMC */ =20 #define APPLESMC_DEFAULT_IOBASE 0x300 -/* data port used by Apple SMC */ -#define APPLESMC_DATA_PORT 0x0 -/* command/status port used by Apple SMC */ -#define APPLESMC_CMD_PORT 0x4 -#define APPLESMC_NR_PORTS 32 =20 -#define APPLESMC_READ_CMD 0x10 -#define APPLESMC_WRITE_CMD 0x11 -#define APPLESMC_GET_KEY_BY_INDEX_CMD 0x12 -#define APPLESMC_GET_KEY_TYPE_CMD 0x13 +enum { + APPLESMC_DATA_PORT =3D 0x00, + APPLESMC_CMD_PORT =3D 0x04, + APPLESMC_NUM_PORTS =3D 0x20, +}; + +enum { + APPLESMC_READ_CMD =3D 0x10, + APPLESMC_WRITE_CMD =3D 0x11, + APPLESMC_GET_KEY_BY_INDEX_CMD =3D 0x12, + APPLESMC_GET_KEY_TYPE_CMD =3D 0x13, +}; =20 #ifdef DEBUG_SMC #define smc_debug(...) fprintf(stderr, "AppleSMC: " __VA_ARGS__) #else -#define smc_debug(...) do { } while(0) +#define smc_debug(...) do { } while (0) #endif =20 static char default_osk[64] =3D "This is a dummy key. Enter the real key " @@ -77,12 +80,11 @@ struct AppleSMCState { uint32_t iobase; uint8_t cmd; uint8_t status; - uint8_t key[4]; + char key[4]; uint8_t read_pos; uint8_t data_len; uint8_t data_pos; uint8_t data[255]; - uint8_t charactic[4]; char *osk; QLIST_HEAD(, AppleSMCData) data_def; }; @@ -93,10 +95,10 @@ static void applesmc_io_cmd_write(void *opaque, hwaddr = addr, uint64_t val, AppleSMCState *s =3D opaque; =20 smc_debug("CMD Write B: %#x =3D %#x\n", addr, val); - switch(val) { - case APPLESMC_READ_CMD: - s->status =3D 0x0c; - break; + switch (val) { + case APPLESMC_READ_CMD: + s->status =3D 0x0c; + break; } s->cmd =3D val; s->read_pos =3D 0; @@ -123,54 +125,54 @@ static void applesmc_io_data_write(void *opaque, hwad= dr addr, uint64_t val, AppleSMCState *s =3D opaque; =20 smc_debug("DATA Write B: %#x =3D %#x\n", addr, val); - switch(s->cmd) { - case APPLESMC_READ_CMD: - if(s->read_pos < 4) { - s->key[s->read_pos] =3D val; - s->status =3D 0x04; - } else if(s->read_pos =3D=3D 4) { - s->data_len =3D val; - s->status =3D 0x05; - s->data_pos =3D 0; - smc_debug("Key =3D %c%c%c%c Len =3D %d\n", s->key[0], - s->key[1], s->key[2], s->key[3], val); - applesmc_fill_data(s); - } - s->read_pos++; - break; + switch (s->cmd) { + case APPLESMC_READ_CMD: + if (s->read_pos < 4) { + s->key[s->read_pos] =3D val; + s->status =3D 0x04; + } else if (s->read_pos =3D=3D 4) { + s->data_len =3D val; + s->status =3D 0x05; + s->data_pos =3D 0; + smc_debug("Key =3D %c%c%c%c Len =3D %d\n", s->key[0], + s->key[1], s->key[2], s->key[3], val); + applesmc_fill_data(s); + } + s->read_pos++; + break; } } =20 -static uint64_t applesmc_io_data_read(void *opaque, hwaddr addr1, - unsigned size) +static uint64_t applesmc_io_data_read(void *opaque, hwaddr addr, unsigned = size) { AppleSMCState *s =3D opaque; uint8_t retval =3D 0; =20 - switch(s->cmd) { - case APPLESMC_READ_CMD: - if(s->data_pos < s->data_len) { - retval =3D s->data[s->data_pos]; - smc_debug("READ_DATA[%d] =3D %#hhx\n", s->data_pos, - retval); - s->data_pos++; - if(s->data_pos =3D=3D s->data_len) { - s->status =3D 0x00; - smc_debug("EOF\n"); - } else - s->status =3D 0x05; + switch (s->cmd) { + case APPLESMC_READ_CMD: + if (s->data_pos < s->data_len) { + retval =3D s->data[s->data_pos]; + smc_debug("READ_DATA[%d] =3D %#hhx\n", s->data_pos, + retval); + s->data_pos++; + if (s->data_pos =3D=3D s->data_len) { + s->status =3D 0x00; + smc_debug("EOF\n"); + } else { + s->status =3D 0x05; } + } } - smc_debug("DATA Read b: %#x =3D %#x\n", addr1, retval); + smc_debug("DATA Read b: %#x =3D %#x\n", addr, retval); =20 return retval; } =20 -static uint64_t applesmc_io_cmd_read(void *opaque, hwaddr addr1, unsigned = size) +static uint64_t applesmc_io_cmd_read(void *opaque, hwaddr addr, unsigned s= ize) { AppleSMCState *s =3D opaque; =20 - smc_debug("CMD Read B: %#x\n", addr1); + smc_debug("CMD Read B: %#x\n", addr); return s->status; } =20 --=20 2.9.3 From nobody Wed Nov 5 12:03:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498222411626280.40678519481196; Fri, 23 Jun 2017 05:53:31 -0700 (PDT) Received: from localhost ([::1]:35398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO5a-00068V-46 for importer@patchew.org; Fri, 23 Jun 2017 08:53:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO0q-0001ef-8o for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOO0m-0004RF-Az for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dOO0m-0004Ou-15 for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:32 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8DE8C05FFCE; Fri, 23 Jun 2017 12:48:30 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02D196C414; Fri, 23 Jun 2017 12:48:27 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 429D341ABF; Fri, 23 Jun 2017 14:48:29 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D8DE8C05FFCE Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D8DE8C05FFCE From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 23 Jun 2017 14:48:28 +0200 Message-Id: <20170623124829.24260-3-kraxel@redhat.com> In-Reply-To: <20170623124829.24260-1-kraxel@redhat.com> References: <20170623124829.24260-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 23 Jun 2017 12:48:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] applesmc: implement error status port X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gabriel L. Somlo" , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: "Gabriel L. Somlo" As of release 10.12.4, OS X (Sierra) refuses to boot unless the AppleSMC supports an additional I/O port, expected to provide an error status code. Update the [cmd|data]_write() and data_read() methods to implement the required state machine, and add I/O region & methods to handle access to the error port. Originally proposed by Eric Shelton based in part on FakeSMC (git://git.assembla.com/fakesmc.git). Signed-off-by: Gabriel Somlo Reviewed-by: Alexander Graf Reviewed-by: Phil Dennis-Jordan Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 1497639316-22202-3-git-send-email-gsomlo@gmail.com Signed-off-by: Gerd Hoffmann --- hw/misc/applesmc.c | 141 +++++++++++++++++++++++++++++++++++++++++++------= ---- 1 file changed, 115 insertions(+), 26 deletions(-) diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c index 6381197728..0d882e8f42 100644 --- a/hw/misc/applesmc.c +++ b/hw/misc/applesmc.c @@ -43,6 +43,7 @@ enum { APPLESMC_DATA_PORT =3D 0x00, APPLESMC_CMD_PORT =3D 0x04, + APPLESMC_ERR_PORT =3D 0x1e, APPLESMC_NUM_PORTS =3D 0x20, }; =20 @@ -53,6 +54,24 @@ enum { APPLESMC_GET_KEY_TYPE_CMD =3D 0x13, }; =20 +enum { + APPLESMC_ST_CMD_DONE =3D 0x00, + APPLESMC_ST_DATA_READY =3D 0x01, + APPLESMC_ST_BUSY =3D 0x02, + APPLESMC_ST_ACK =3D 0x04, + APPLESMC_ST_NEW_CMD =3D 0x08, +}; + +enum { + APPLESMC_ST_1E_CMD_INTRUPTED =3D 0x80, + APPLESMC_ST_1E_STILL_BAD_CMD =3D 0x81, + APPLESMC_ST_1E_BAD_CMD =3D 0x82, + APPLESMC_ST_1E_NOEXIST =3D 0x84, + APPLESMC_ST_1E_WRITEONLY =3D 0x85, + APPLESMC_ST_1E_READONLY =3D 0x86, + APPLESMC_ST_1E_BAD_INDEX =3D 0xb8, +}; + #ifdef DEBUG_SMC #define smc_debug(...) fprintf(stderr, "AppleSMC: " __VA_ARGS__) #else @@ -77,9 +96,12 @@ struct AppleSMCState { =20 MemoryRegion io_data; MemoryRegion io_cmd; + MemoryRegion io_err; uint32_t iobase; uint8_t cmd; uint8_t status; + uint8_t status_1e; + uint8_t last_ret; char key[4]; uint8_t read_pos; uint8_t data_len; @@ -93,89 +115,138 @@ static void applesmc_io_cmd_write(void *opaque, hwadd= r addr, uint64_t val, unsigned size) { AppleSMCState *s =3D opaque; + uint8_t status =3D s->status & 0x0f; =20 - smc_debug("CMD Write B: %#x =3D %#x\n", addr, val); + smc_debug("CMD received: 0x%02x\n", (uint8_t)val); switch (val) { case APPLESMC_READ_CMD: - s->status =3D 0x0c; + /* did last command run through OK? */ + if (status =3D=3D APPLESMC_ST_CMD_DONE || status =3D=3D APPLESMC_S= T_NEW_CMD) { + s->cmd =3D val; + s->status =3D APPLESMC_ST_NEW_CMD | APPLESMC_ST_ACK; + } else { + smc_debug("ERROR: previous command interrupted!\n"); + s->status =3D APPLESMC_ST_NEW_CMD; + s->status_1e =3D APPLESMC_ST_1E_CMD_INTRUPTED; + } break; + default: + smc_debug("UNEXPECTED CMD 0x%02x\n", (uint8_t)val); + s->status =3D APPLESMC_ST_NEW_CMD; + s->status_1e =3D APPLESMC_ST_1E_BAD_CMD; } - s->cmd =3D val; s->read_pos =3D 0; s->data_pos =3D 0; } =20 -static void applesmc_fill_data(AppleSMCState *s) +static struct AppleSMCData *applesmc_find_key(AppleSMCState *s) { struct AppleSMCData *d; =20 QLIST_FOREACH(d, &s->data_def, node) { if (!memcmp(d->key, s->key, 4)) { - smc_debug("Key matched (%s Len=3D%d Data=3D%s)\n", d->key, - d->len, d->data); - memcpy(s->data, d->data, d->len); - return; + return d; } } + return NULL; } =20 static void applesmc_io_data_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { AppleSMCState *s =3D opaque; + struct AppleSMCData *d; =20 - smc_debug("DATA Write B: %#x =3D %#x\n", addr, val); + smc_debug("DATA received: 0x%02x\n", (uint8_t)val); switch (s->cmd) { case APPLESMC_READ_CMD: + if ((s->status & 0x0f) =3D=3D APPLESMC_ST_CMD_DONE) { + break; + } if (s->read_pos < 4) { s->key[s->read_pos] =3D val; - s->status =3D 0x04; + s->status =3D APPLESMC_ST_ACK; } else if (s->read_pos =3D=3D 4) { - s->data_len =3D val; - s->status =3D 0x05; - s->data_pos =3D 0; - smc_debug("Key =3D %c%c%c%c Len =3D %d\n", s->key[0], - s->key[1], s->key[2], s->key[3], val); - applesmc_fill_data(s); + d =3D applesmc_find_key(s); + if (d !=3D NULL) { + memcpy(s->data, d->data, d->len); + s->data_len =3D d->len; + s->data_pos =3D 0; + s->status =3D APPLESMC_ST_ACK | APPLESMC_ST_DATA_READY; + s->status_1e =3D APPLESMC_ST_CMD_DONE; /* clear on valid = key */ + } else { + smc_debug("READ_CMD: key '%c%c%c%c' not found!\n", + s->key[0], s->key[1], s->key[2], s->key[3]); + s->status =3D APPLESMC_ST_CMD_DONE; + s->status_1e =3D APPLESMC_ST_1E_NOEXIST; + } } s->read_pos++; break; + default: + s->status =3D APPLESMC_ST_CMD_DONE; + s->status_1e =3D APPLESMC_ST_1E_STILL_BAD_CMD; } } =20 +static void applesmc_io_err_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + smc_debug("ERR_CODE received: 0x%02x, ignoring!\n", (uint8_t)val); + /* NOTE: writing to the error port not supported! */ +} + static uint64_t applesmc_io_data_read(void *opaque, hwaddr addr, unsigned = size) { AppleSMCState *s =3D opaque; - uint8_t retval =3D 0; =20 switch (s->cmd) { case APPLESMC_READ_CMD: + if (!(s->status & APPLESMC_ST_DATA_READY)) { + break; + } if (s->data_pos < s->data_len) { - retval =3D s->data[s->data_pos]; - smc_debug("READ_DATA[%d] =3D %#hhx\n", s->data_pos, - retval); + s->last_ret =3D s->data[s->data_pos]; + smc_debug("READ '%c%c%c%c'[%d] =3D %02x\n", + s->key[0], s->key[1], s->key[2], s->key[3], + s->data_pos, s->last_ret); s->data_pos++; if (s->data_pos =3D=3D s->data_len) { - s->status =3D 0x00; - smc_debug("EOF\n"); + s->status =3D APPLESMC_ST_CMD_DONE; + smc_debug("READ '%c%c%c%c' Len=3D%d complete!\n", + s->key[0], s->key[1], s->key[2], s->key[3], + s->data_len); } else { - s->status =3D 0x05; + s->status =3D APPLESMC_ST_ACK | APPLESMC_ST_DATA_READY; } } + break; + default: + s->status =3D APPLESMC_ST_CMD_DONE; + s->status_1e =3D APPLESMC_ST_1E_STILL_BAD_CMD; } - smc_debug("DATA Read b: %#x =3D %#x\n", addr, retval); + smc_debug("DATA sent: 0x%02x\n", s->last_ret); =20 - return retval; + return s->last_ret; } =20 static uint64_t applesmc_io_cmd_read(void *opaque, hwaddr addr, unsigned s= ize) { AppleSMCState *s =3D opaque; =20 - smc_debug("CMD Read B: %#x\n", addr); + smc_debug("CMD sent: 0x%02x\n", s->status); return s->status; } =20 +static uint64_t applesmc_io_err_read(void *opaque, hwaddr addr, unsigned s= ize) +{ + AppleSMCState *s =3D opaque; + + /* NOTE: read does not clear the 1e status */ + smc_debug("ERR_CODE sent: 0x%02x\n", s->status_1e); + return s->status_1e; +} + static void applesmc_add_key(AppleSMCState *s, const char *key, int len, const char *data) { @@ -198,6 +269,9 @@ static void qdev_applesmc_isa_reset(DeviceState *dev) QLIST_FOREACH_SAFE(d, &s->data_def, node, next) { QLIST_REMOVE(d, node); } + s->status =3D 0x00; + s->status_1e =3D 0x00; + s->last_ret =3D 0x00; =20 applesmc_add_key(s, "REV ", 6, "\x01\x13\x0f\x00\x00\x03"); applesmc_add_key(s, "OSK0", 32, s->osk); @@ -227,6 +301,16 @@ static const MemoryRegionOps applesmc_cmd_io_ops =3D { }, }; =20 +static const MemoryRegionOps applesmc_err_io_ops =3D { + .write =3D applesmc_io_err_write, + .read =3D applesmc_io_err_read, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + static void applesmc_isa_realize(DeviceState *dev, Error **errp) { AppleSMCState *s =3D APPLE_SMC(dev); @@ -241,6 +325,11 @@ static void applesmc_isa_realize(DeviceState *dev, Err= or **errp) isa_register_ioport(&s->parent_obj, &s->io_cmd, s->iobase + APPLESMC_CMD_PORT); =20 + memory_region_init_io(&s->io_err, OBJECT(s), &applesmc_err_io_ops, s, + "applesmc-err", 1); + isa_register_ioport(&s->parent_obj, &s->io_err, + s->iobase + APPLESMC_ERR_PORT); + if (!s->osk || (strlen(s->osk) !=3D 64)) { fprintf(stderr, "WARNING: Using AppleSMC with invalid key\n"); s->osk =3D default_osk; --=20 2.9.3 From nobody Wed Nov 5 12:03:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498222400873357.3564005248164; Fri, 23 Jun 2017 05:53:20 -0700 (PDT) Received: from localhost ([::1]:35397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO5P-0005zH-8x for importer@patchew.org; Fri, 23 Jun 2017 08:53:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dOO0r-0001iH-5d for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dOO0n-0004SL-5d for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dOO0m-0004Qs-TM for qemu-devel@nongnu.org; Fri, 23 Jun 2017 08:48:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAAACB9AC3; Fri, 23 Jun 2017 12:48:31 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05A966EC7B; Fri, 23 Jun 2017 12:48:27 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4996A41CA1; Fri, 23 Jun 2017 14:48:29 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BAAACB9AC3 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BAAACB9AC3 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 23 Jun 2017 14:48:29 +0200 Message-Id: <20170623124829.24260-4-kraxel@redhat.com> In-Reply-To: <20170623124829.24260-1-kraxel@redhat.com> References: <20170623124829.24260-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Jun 2017 12:48:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/3] applesmc: fix port i/o access width X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gabriel L. Somlo" , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Gabriel L. Somlo" Set access width of all AppleSMC i/o regions to 1 byte, since they all represent 8-bit-wide ports. Signed-off-by: Gabriel Somlo Reviewed-by: Alexander Graf Message-id: 1497639316-22202-4-git-send-email-gsomlo@gmail.com Signed-off-by: Gerd Hoffmann --- hw/misc/applesmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c index 0d882e8f42..7896812304 100644 --- a/hw/misc/applesmc.c +++ b/hw/misc/applesmc.c @@ -316,12 +316,12 @@ static void applesmc_isa_realize(DeviceState *dev, Er= ror **errp) AppleSMCState *s =3D APPLE_SMC(dev); =20 memory_region_init_io(&s->io_data, OBJECT(s), &applesmc_data_io_ops, s, - "applesmc-data", 4); + "applesmc-data", 1); isa_register_ioport(&s->parent_obj, &s->io_data, s->iobase + APPLESMC_DATA_PORT); =20 memory_region_init_io(&s->io_cmd, OBJECT(s), &applesmc_cmd_io_ops, s, - "applesmc-cmd", 4); + "applesmc-cmd", 1); isa_register_ioport(&s->parent_obj, &s->io_cmd, s->iobase + APPLESMC_CMD_PORT); =20 --=20 2.9.3