From nobody Thu Nov 28 10:39:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1693828498; cv=none; d=zohomail.com; s=zohoarc; b=WUlJpY5L9Qg2ah74v8xf8BWRpq93YXvQ/rMjDFq8+Q6phTPJ2lkzqZAYPOLl6z1A5jzzyDl44/7wn+BsNy0+LPlIwfnwZBy9m1fmsFoe15xAdZh0to3++eEHCdLEBoaIOvRgCWn79OARePatpkcXLR6VwIzLXkyDOPFbjw+qZoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693828498; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=67R2icKCU8YB0ua7cyVSlvlDLBodUe6L8J6s+JEpyy0=; b=a1Hwpg4nB5tj403Y8XgHGzKWQFhw5t5tjQI32FsATcRtZSwEoZY2lySdC1hSRbOjASrFIm6kfpkx8d9RwCS/g08FYB7mMJfqPpZSVxbAPIUW9n8767vmXB8iMrJOxjtzKHJEkWd9eQmfm/GuDriRwpYMhd21kAcWEYSVwGc/pHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693828498878422.5414756942123; Mon, 4 Sep 2023 04:54:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qd89c-0002r1-WD; Mon, 04 Sep 2023 07:54:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qd89Z-0002bY-JT for qemu-devel@nongnu.org; Mon, 04 Sep 2023 07:54:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qd89V-0008Ot-V8 for qemu-devel@nongnu.org; Mon, 04 Sep 2023 07:54:00 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-RtBo4lVQNfGMfJRXm5P_MA-1; Mon, 04 Sep 2023 07:53:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1FE763C01E02 for ; Mon, 4 Sep 2023 11:53:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D61F40C84A6; Mon, 4 Sep 2023 11:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693828435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=67R2icKCU8YB0ua7cyVSlvlDLBodUe6L8J6s+JEpyy0=; b=ae/68eVWK1FqUZtjJTW7p9z+DE1C6Qh6Uq+Ir7VAwRH9Pzd0F8JOPFhh4ROHXxF0F/IfZz F03kgtZUNIu0TKstl4Rz3XitK6McHXP26Fbe/JZHiQgFIPDXVgY49OUl4/InTrn5PX0og/ AXk/tXFl2X8pOlNzh+sZpVNUXoy9qlM= X-MC-Unique: RtBo4lVQNfGMfJRXm5P_MA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 15/52] ui/vc: pass VCCharDev to VC-specific functions Date: Mon, 4 Sep 2023 15:52:12 +0400 Message-ID: <20230904115251.4161397-16-marcandre.lureau@redhat.com> In-Reply-To: <20230904115251.4161397-1-marcandre.lureau@redhat.com> References: <20230904115251.4161397-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693828500114100003 From: Marc-Andr=C3=A9 Lureau Even though they actually use more of QemuConsole at this point, it makes it clearer those functions are only used from the chardev implementation. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20230830093843.3531473-16-marcandre.lureau@redhat.com> --- ui/console.c | 70 +++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/ui/console.c b/ui/console.c index 405aedfcbd..f9ed012e1c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -440,8 +440,9 @@ static void invalidate_xy(QemuConsole *s, int x, int y) s->update_y1 =3D (y + 1) * FONT_HEIGHT; } =20 -static void update_xy(QemuConsole *s, int x, int y) +static void vc_update_xy(VCChardev *vc, int x, int y) { + QemuConsole *s =3D vc->console; TextCell *c; int y1, y2; =20 @@ -555,8 +556,9 @@ static void console_scroll(QemuConsole *s, int ydelta) console_refresh(s); } =20 -static void console_put_lf(QemuConsole *s) +static void vc_put_lf(VCChardev *vc) { + QemuConsole *s =3D vc->console; TextCell *c; int x, y1; =20 @@ -603,8 +605,9 @@ static void console_put_lf(QemuConsole *s) * NOTE: I know this code is not very efficient (checking every color for = it * self) but it is more readable and better maintainable. */ -static void console_handle_escape(QemuConsole *s) +static void vc_handle_escape(VCChardev *vc) { + QemuConsole *s =3D vc->console; int i; =20 for (i=3D0; inb_esc_params; i++) { @@ -696,8 +699,9 @@ static void console_handle_escape(QemuConsole *s) } } =20 -static void console_clear_xy(QemuConsole *s, int x, int y) +static void vc_clear_xy(VCChardev *vc, int x, int y) { + QemuConsole *s =3D vc->console; int y1 =3D (s->y_base + y) % s->total_height; if (x >=3D s->width) { x =3D s->width - 1; @@ -705,37 +709,40 @@ static void console_clear_xy(QemuConsole *s, int x, i= nt y) TextCell *c =3D &s->cells[y1 * s->width + x]; c->ch =3D ' '; c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - update_xy(s, x, y); + vc_update_xy(vc, x, y); } =20 -static void console_put_one(QemuConsole *s, int ch) +static void vc_put_one(VCChardev *vc, int ch) { + QemuConsole *s =3D vc->console; TextCell *c; int y1; if (s->x >=3D s->width) { /* line wrap */ s->x =3D 0; - console_put_lf(s); + vc_put_lf(vc); } y1 =3D (s->y_base + s->y) % s->total_height; c =3D &s->cells[y1 * s->width + s->x]; c->ch =3D ch; c->t_attrib =3D s->t_attrib; - update_xy(s, s->x, s->y); + vc_update_xy(vc, s->x, s->y); s->x++; } =20 -static void console_respond_str(QemuConsole *s, const char *buf) +static void vc_respond_str(VCChardev *vc, const char *buf) { while (*buf) { - console_put_one(s, *buf); + vc_put_one(vc, *buf); buf++; } } =20 /* set cursor, checking bounds */ -static void set_cursor(QemuConsole *s, int x, int y) +static void vc_set_cursor(VCChardev *vc, int x, int y) { + QemuConsole *s =3D vc->console; + if (x < 0) { x =3D 0; } @@ -753,8 +760,9 @@ static void set_cursor(QemuConsole *s, int x, int y) s->y =3D y; } =20 -static void console_putchar(QemuConsole *s, int ch) +static void vc_putchar(VCChardev *vc, int ch) { + QemuConsole *s =3D vc->console; int i; int x, y; char response[40]; @@ -766,7 +774,7 @@ static void console_putchar(QemuConsole *s, int ch) s->x =3D 0; break; case '\n': /* newline */ - console_put_lf(s); + vc_put_lf(vc); break; case '\b': /* backspace */ if (s->x > 0) @@ -775,7 +783,7 @@ static void console_putchar(QemuConsole *s, int ch) case '\t': /* tabspace */ if (s->x + (8 - (s->x % 8)) > s->width) { s->x =3D 0; - console_put_lf(s); + vc_put_lf(vc); } else { s->x =3D s->x + (8 - (s->x % 8)); } @@ -793,7 +801,7 @@ static void console_putchar(QemuConsole *s, int ch) s->state =3D TTY_STATE_ESC; break; default: - console_put_one(s, ch); + vc_put_one(vc, ch); break; } break; @@ -831,37 +839,37 @@ static void console_putchar(QemuConsole *s, int ch) if (s->esc_params[0] =3D=3D 0) { s->esc_params[0] =3D 1; } - set_cursor(s, s->x, s->y - s->esc_params[0]); + vc_set_cursor(vc, s->x, s->y - s->esc_params[0]); break; case 'B': /* move cursor down */ if (s->esc_params[0] =3D=3D 0) { s->esc_params[0] =3D 1; } - set_cursor(s, s->x, s->y + s->esc_params[0]); + vc_set_cursor(vc, s->x, s->y + s->esc_params[0]); break; case 'C': /* move cursor right */ if (s->esc_params[0] =3D=3D 0) { s->esc_params[0] =3D 1; } - set_cursor(s, s->x + s->esc_params[0], s->y); + vc_set_cursor(vc, s->x + s->esc_params[0], s->y); break; case 'D': /* move cursor left */ if (s->esc_params[0] =3D=3D 0) { s->esc_params[0] =3D 1; } - set_cursor(s, s->x - s->esc_params[0], s->y); + vc_set_cursor(vc, s->x - s->esc_params[0], s->y); break; case 'G': /* move cursor to column */ - set_cursor(s, s->esc_params[0] - 1, s->y); + vc_set_cursor(vc, s->esc_params[0] - 1, s->y); break; case 'f': case 'H': /* move cursor to row, column */ - set_cursor(s, s->esc_params[1] - 1, s->esc_params[0] - 1); + vc_set_cursor(vc, s->esc_params[1] - 1, s->esc_params[0] -= 1); break; case 'J': switch (s->esc_params[0]) { @@ -872,7 +880,7 @@ static void console_putchar(QemuConsole *s, int ch) if (y =3D=3D s->y && x < s->x) { continue; } - console_clear_xy(s, x, y); + vc_clear_xy(vc, x, y); } } break; @@ -883,7 +891,7 @@ static void console_putchar(QemuConsole *s, int ch) if (y =3D=3D s->y && x > s->x) { break; } - console_clear_xy(s, x, y); + vc_clear_xy(vc, x, y); } } break; @@ -891,7 +899,7 @@ static void console_putchar(QemuConsole *s, int ch) /* clear entire screen */ for (y =3D 0; y <=3D s->height; y++) { for (x =3D 0; x < s->width; x++) { - console_clear_xy(s, x, y); + vc_clear_xy(vc, x, y); } } break; @@ -902,38 +910,38 @@ static void console_putchar(QemuConsole *s, int ch) case 0: /* clear to eol */ for(x =3D s->x; x < s->width; x++) { - console_clear_xy(s, x, s->y); + vc_clear_xy(vc, x, s->y); } break; case 1: /* clear from beginning of line */ for (x =3D 0; x <=3D s->x && x < s->width; x++) { - console_clear_xy(s, x, s->y); + vc_clear_xy(vc, x, s->y); } break; case 2: /* clear entire line */ for(x =3D 0; x < s->width; x++) { - console_clear_xy(s, x, s->y); + vc_clear_xy(vc, x, s->y); } break; } break; case 'm': - console_handle_escape(s); + vc_handle_escape(vc); break; case 'n': switch (s->esc_params[0]) { case 5: /* report console status (always succeed)*/ - console_respond_str(s, "\033[0n"); + vc_respond_str(vc, "\033[0n"); break; case 6: /* report cursor position */ sprintf(response, "\033[%d;%dR", (s->y_base + s->y) % s->total_height + 1, s->x + 1); - console_respond_str(s, response); + vc_respond_str(vc, response); break; } break; @@ -1072,7 +1080,7 @@ static int vc_chr_write(Chardev *chr, const uint8_t *= buf, int len) s->update_y1 =3D 0; console_show_cursor(s, 0); for(i =3D 0; i < len; i++) { - console_putchar(s, buf[i]); + vc_putchar(drv, buf[i]); } console_show_cursor(s, 1); if (s->update_x0 < s->update_x1) { --=20 2.41.0