From patchwork Fri Jun 16 18:55:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 9793305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 711E76038F for ; Fri, 16 Jun 2017 18:56:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 645C32865B for ; Fri, 16 Jun 2017 18:56:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5958F28670; Fri, 16 Jun 2017 18:56:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B35F62866B for ; Fri, 16 Jun 2017 18:56:43 +0000 (UTC) Received: from localhost ([::1]:60363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwQE-0004Wd-Sg for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Jun 2017 14:56:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dLwP8-0004UC-0B for qemu-devel@nongnu.org; Fri, 16 Jun 2017 14:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dLwP4-0006Vn-VT for qemu-devel@nongnu.org; Fri, 16 Jun 2017 14:55:34 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:35154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dLwP4-0006VT-Oa for qemu-devel@nongnu.org; Fri, 16 Jun 2017 14:55:30 -0400 Received: by mail-qt0-x243.google.com with SMTP id x58so12311428qtc.2 for ; Fri, 16 Jun 2017 11:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M0hrBPj98L0Abphw0y7Hb8yBcCDe37S+V9NYSxSOSM0=; b=LIE5qPshAL2h93nlAPzf6oOtLUi92bZ426wFOVvNdpBlPpadbtOiT1xAHTidMT2cdx 0vCEJwt24FUAyr3PSVcmzd+nX4v5q45c7mFqIA8MiTwUU/UxlqXtQBJBwbRn5KC4bkZz /Nb+/eERroer/EVCp7N8r68BywdIoDh1Je8tVbv/ZJ8qTOEvCYYmBtzKgkzQbkfGED+Z gT0xr5jcVwhptqHT3gHJzLl9A3iHOI8yC4v2g1ThR+2Whnk4l5NdFZAB94+LDcPd0k5G xAC1xUur//HHlJnnYaov2mU0snnnbWkoQIA4Qj3FASQc/uRZDTR/bqBBEidevtbWx+X4 9GBQ== 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:mime-version:content-transfer-encoding; bh=M0hrBPj98L0Abphw0y7Hb8yBcCDe37S+V9NYSxSOSM0=; b=ZDbPCUr67UqXOCQWWwaf11UVi8Iklo+Atwqth7eD0KfVEdwnlyNbfrWLkvjAyeei49 tO0vIL5AslzX/NjmF7F+IWW2WBalJxTHWnVq+3EV3mopBgYuLInqL53dz5vd/zZ/ADUs Xt0Uy++JiGgmcvKUkFanx6pVnsBHckiPaFNy+j/Ccv5eZjh5F3ct2JoWi+XT35xkryWH Nm9jRZuuyZRDlCkUfdvpdE5aAUNzb6Z+tVoCzTh08fWOhg4+UJjsYlHFmUAHmD3wn/rU uloxNz+0pvs4MfbZ5SPkakJiAUfKeQwPfQ9XAZ0/e3UBUKbUrDjfGD4hsLh5BFlA4C6T OhMg== X-Gm-Message-State: AKS2vOyuCHQcMa6DAMkGaLLfiNUsFwJ5KMbmAGBlZZrlCiKXCnWcZO5H BPK1Yh6aRr3oM4/m X-Received: by 10.55.148.67 with SMTP id w64mr14375414qkd.160.1497639329786; Fri, 16 Jun 2017 11:55:29 -0700 (PDT) Received: from HEDWIG.ini.cmu.edu (HEDWIG.INI.CMU.EDU. [128.2.16.51]) by smtp.gmail.com with ESMTPSA id p24sm1761565qki.49.2017.06.16.11.55.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 11:55:28 -0700 (PDT) From: "Gabriel L. Somlo" To: qemu-devel@nongnu.org Date: Fri, 16 Jun 2017 14:55:14 -0400 Message-Id: <1497639316-22202-2-git-send-email-gsomlo@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497639316-22202-1-git-send-email-gsomlo@gmail.com> References: <1497639316-22202-1-git-send-email-gsomlo@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v3 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: pbonzini@redhat.com, eshelton@pobox.com, agraf@suse.de, f4bug@amsat.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gabriel Somlo Reviewed-by: Alexander Graf Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Phil Dennis-Jordan --- 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 77fab5b..6381197 100644 --- a/hw/misc/applesmc.c +++ b/hw/misc/applesmc.c @@ -39,21 +39,24 @@ /* #define DEBUG_SMC */ #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 -#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 = 0x00, + APPLESMC_CMD_PORT = 0x04, + APPLESMC_NUM_PORTS = 0x20, +}; + +enum { + APPLESMC_READ_CMD = 0x10, + APPLESMC_WRITE_CMD = 0x11, + APPLESMC_GET_KEY_BY_INDEX_CMD = 0x12, + APPLESMC_GET_KEY_TYPE_CMD = 0x13, +}; #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 static char default_osk[64] = "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 = opaque; smc_debug("CMD Write B: %#x = %#x\n", addr, val); - switch(val) { - case APPLESMC_READ_CMD: - s->status = 0x0c; - break; + switch (val) { + case APPLESMC_READ_CMD: + s->status = 0x0c; + break; } s->cmd = val; s->read_pos = 0; @@ -123,54 +125,54 @@ static void applesmc_io_data_write(void *opaque, hwaddr addr, uint64_t val, AppleSMCState *s = opaque; smc_debug("DATA Write B: %#x = %#x\n", addr, val); - switch(s->cmd) { - case APPLESMC_READ_CMD: - if(s->read_pos < 4) { - s->key[s->read_pos] = val; - s->status = 0x04; - } else if(s->read_pos == 4) { - s->data_len = val; - s->status = 0x05; - s->data_pos = 0; - smc_debug("Key = %c%c%c%c Len = %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] = val; + s->status = 0x04; + } else if (s->read_pos == 4) { + s->data_len = val; + s->status = 0x05; + s->data_pos = 0; + smc_debug("Key = %c%c%c%c Len = %d\n", s->key[0], + s->key[1], s->key[2], s->key[3], val); + applesmc_fill_data(s); + } + s->read_pos++; + break; } } -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 = opaque; uint8_t retval = 0; - switch(s->cmd) { - case APPLESMC_READ_CMD: - if(s->data_pos < s->data_len) { - retval = s->data[s->data_pos]; - smc_debug("READ_DATA[%d] = %#hhx\n", s->data_pos, - retval); - s->data_pos++; - if(s->data_pos == s->data_len) { - s->status = 0x00; - smc_debug("EOF\n"); - } else - s->status = 0x05; + switch (s->cmd) { + case APPLESMC_READ_CMD: + if (s->data_pos < s->data_len) { + retval = s->data[s->data_pos]; + smc_debug("READ_DATA[%d] = %#hhx\n", s->data_pos, + retval); + s->data_pos++; + if (s->data_pos == s->data_len) { + s->status = 0x00; + smc_debug("EOF\n"); + } else { + s->status = 0x05; } + } } - smc_debug("DATA Read b: %#x = %#x\n", addr1, retval); + smc_debug("DATA Read b: %#x = %#x\n", addr, retval); return retval; } -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 size) { AppleSMCState *s = opaque; - smc_debug("CMD Read B: %#x\n", addr1); + smc_debug("CMD Read B: %#x\n", addr); return s->status; }