From nobody Wed Dec 4 08:28:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 173101471224950.721942035400275; Thu, 7 Nov 2024 13:25:12 -0800 (PST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 59A9AED2D1; Thu, 7 Nov 2024 21:25:07 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 8C797ED2E1 for ; Thu, 7 Nov 2024 21:24:50 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Thu, 07 Nov 2024 13:24:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731014689; x=1731619489; darn=seabios.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=5WsVgWMIF1UuQerbXHdAUuUNeVEyO5ruHDDEBZ7zw00=; b=ReUqcHJFu083MQq5ewYBgeNWy4qLTX7Xo1SiRzZgTYAaZPWvB+1odQIjtRYs624sbD Wz0wzgDvmx8pSNwzkRM5PWqo/dT7XzP9GUVWPAUGxmbhutLjW5JESAWdwi3EcacswKzL 9WFh0kiVlIygXjpwamaAyCAHWNfmwgh37DlUkmaYF8LOZMFNRg8CtzzxucJbRpDmz5aa fnzigULlok9bX+MVSoo8C+Dc7lPP3Tig33bY9rgD1FntWwQlUHoGGuAv6WXq55gKbqaf F4xMtrs0G1VgjuSRszgUcnj3XCaCyImsX9JpGiiEM/m+SCVPNPCH96zqR7VImHJrIlLq Eeog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731014689; x=1731619489; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5WsVgWMIF1UuQerbXHdAUuUNeVEyO5ruHDDEBZ7zw00=; b=NXLHWZRNPrA4hNjggQjlfN4Rl+NATDJ/MdDKbIIgb6HJ6n4QC4I+dkH5/Pxx8uDvMK pp2EZEW8Y1TTRBpKaFmC+DUeMtyFnOjbGMJOOaG+R3ym0vN6lwO3HgQ3kmO5Y/RFdz41 FNYP6/K89aLEU+v00/M7tC/pII5EVwGOFveJLrM62P9czwwRJEMBvNobuZBjpWDSkNBg 3jcmk+DEzYWph8iQMEGB8aNRIIeqHTkQqRzJg+kUc2BlHzUb08R+x4sFP5McO9h84Gbh ko7bco1WUb9ffXZ8f57qjWWvCxV4e/3wrB+nq1hG+29rkdRAr2tAP99cwrmzjlOVE87Q fdfg== X-Gm-Message-State: AOJu0YxY/TCDvm9pEE3QvLh5PbGZrgVeFGOXuSgREur9i5hNI5w243kF ZS/JywW/faBQo4NT6S+d2+W4o2c5q2+R+4E+8mJcqghJLKoJRe993U3d0CG51ius4bKcFqtyUQP 4hsKcfAPMPDlfD/iLbHUkMhxb+aED7ZXH X-Google-Smtp-Source: AGHT+IFE2b0SIchOEXarYyQ0PoZfX/DPgrNa42n+i0EyDrJ6qplnAAfhCJzjY6xEIO8s+ZNGmaWs34Wi8qBSJ2CSDC4= X-Received: by 2002:a05:6820:4c89:b0:5eb:821c:df23 with SMTP id 006d021491bc7-5ee57b96a9bmr787612eaf.2.1731014688598; Thu, 07 Nov 2024 13:24:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Daniel Khodabakhsh Date: Thu, 7 Nov 2024 21:24:36 +0000 Message-ID: To: seabios@seabios.org Content-Type: multipart/mixed; boundary="0000000000009d94fa0626594331" Message-ID-Hash: BXZTGZLL6P7WP4H56CG5ATZ7LA63NMBY X-Message-ID-Hash: BXZTGZLL6P7WP4H56CG5ATZ7LA63NMBY X-MailFrom: d.khodabakhsh@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [SeaBIOS] Re: [PATCH] Support multiple USB HID keyboards/mice List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-Zoho-Virus-Status: 1 X-Zoho-AV-Stamp: zmail-av-1.3.1/230.957.89 X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1731014713618116600 --0000000000009d94fa0626594331 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reworked the change a bit to escalate memory errors allowing usb.c:configure_usb_device() to free memory during device initialisation. Also removed some code duplication. From f6a653b0fcac0359d598c342ed0a51b05d6ebe16 Mon Sep 17 00:00:00 2001 From: Daniel Khodabakhsh Date: Thu, 7 Nov 2024 10:34:47 -0800 Subject: [PATCH] Support multiple USB HID devices by storing them in a link= ed list. --- src/hw/usb-hid.c | 121 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 39 deletions(-) diff --git a/src/hw/usb-hid.c b/src/hw/usb-hid.c index dec198ac..2350e121 100644 --- a/src/hw/usb-hid.c +++ b/src/hw/usb-hid.c @@ -1,20 +1,54 @@ // Code for handling USB Human Interface Devices (HID). // // Copyright (C) 2009 Kevin O'Connor +// Copyright (C) 2024 Daniel Khodabakhsh // // This file may be distributed under the terms of the GNU LGPLv3 license. #include "biosvar.h" // GET_GLOBAL #include "config.h" // CONFIG_* -#include "output.h" // dprintf +#include "output.h" // dprintf, warn_noalloc +#include "malloc.h" // malloc_fseg #include "ps2port.h" // ATKBD_CMD_GETID +#include "stacks.h" // mutex_lock, mutex_unlock #include "usb.h" // usb_ctrlrequest #include "usb-hid.h" // usb_keyboard_setup #include "util.h" // process_key -struct usb_pipe *keyboard_pipe VARFSEG; -struct usb_pipe *mouse_pipe VARFSEG; +struct pipe_node { + struct usb_pipe *pipe; + struct pipe_node *next; +}; + +struct mutex_s usb_hid_lock; + +struct pipe_node *keyboard_pipe_node VARFSEG =3D NULL; +struct pipe_node *mouse_pipe_node VARFSEG =3D NULL; +static int +add_pipe_node(struct pipe_node **root_node + , struct usbdevice_s *usbdev + , struct usb_endpoint_descriptor *epdesc) +{ + struct usb_pipe *pipe =3D usb_alloc_pipe(usbdev, epdesc); + if (!pipe) + return -1; + + struct pipe_node *new_root_node =3D malloc_fseg(sizeof(struct pipe_nod= e)); + if (!new_root_node) { + warn_noalloc(); + return -1; + } + + new_root_node->pipe =3D pipe; + + mutex_lock(&usb_hid_lock); + new_root_node->next =3D *root_node; + *root_node =3D new_root_node; + mutex_unlock(&usb_hid_lock); + + return 0; +} /**************************************************************** * Setup @@ -64,9 +98,6 @@ usb_kbd_setup(struct usbdevice_s *usbdev { if (! CONFIG_USB_KEYBOARD) return -1; - if (keyboard_pipe) - // XXX - this enables the first found keyboard (could be random) - return -1; if (epdesc->wMaxPacketSize < sizeof(struct keyevent) || epdesc->wMaxPacketSize > MAX_KBD_EVENT) { @@ -76,19 +107,16 @@ usb_kbd_setup(struct usbdevice_s *usbdev } // Enable "boot" protocol. - int ret =3D set_protocol(usbdev->defpipe, 0, usbdev->iface->bInterfaceNumber); - if (ret) { + if (set_protocol(usbdev->defpipe, 0, usbdev->iface->bInterfaceNumber))= { dprintf(3, "Failed to set boot protocol\n"); return -1; } // Periodically send reports to enable key repeat. - ret =3D set_idle(usbdev->defpipe, KEYREPEATMS); - if (ret) + if (set_idle(usbdev->defpipe, KEYREPEATMS)) dprintf(3, "Warning: Failed to set key repeat rate\n"); - keyboard_pipe =3D usb_alloc_pipe(usbdev, epdesc); - if (!keyboard_pipe) + if (add_pipe_node(&keyboard_pipe_node, usbdev, epdesc)) return -1; dprintf(1, "USB keyboard initialized\n"); @@ -109,9 +137,6 @@ usb_mouse_setup(struct usbdevice_s *usbdev { if (! CONFIG_USB_MOUSE) return -1; - if (mouse_pipe) - // XXX - this enables the first found mouse (could be random) - return -1; if (epdesc->wMaxPacketSize < sizeof(struct mouseevent) || epdesc->wMaxPacketSize > MAX_MOUSE_EVENT) { @@ -121,12 +146,10 @@ usb_mouse_setup(struct usbdevice_s *usbdev } // Enable "boot" protocol. - int ret =3D set_protocol(usbdev->defpipe, 0, usbdev->iface->bInterfaceNumber); - if (ret) + if (set_protocol(usbdev->defpipe, 0, usbdev->iface->bInterfaceNumber)) return -1; - mouse_pipe =3D usb_alloc_pipe(usbdev, epdesc); - if (!mouse_pipe) + if (add_pipe_node(&mouse_pipe_node, usbdev, epdesc)) return -1; dprintf(1, "USB mouse initialized\n"); @@ -325,16 +348,20 @@ usb_check_key(void) { if (! CONFIG_USB_KEYBOARD) return; - struct usb_pipe *pipe =3D GET_GLOBAL(keyboard_pipe); - if (!pipe) - return; - for (;;) { - u8 data[MAX_KBD_EVENT]; - int ret =3D usb_poll_intr(pipe, data); - if (ret) - break; - handle_key((void*)data); + for (struct pipe_node *node =3D GET_GLOBAL(keyboard_pipe_node); node; node =3D GET_GLOBALFLAT(node->next)) { + struct usb_pipe *pipe =3D GET_GLOBALFLAT(node->pipe); + + if (!pipe) + continue; + + for (;;) { + u8 data[MAX_KBD_EVENT]; + int ret =3D usb_poll_intr(pipe, data); + if (ret) + break; + handle_key((void*)data); + } } } @@ -344,7 +371,13 @@ usb_kbd_active(void) { if (! CONFIG_USB_KEYBOARD) return 0; - return GET_GLOBAL(keyboard_pipe) !=3D NULL; + + for (struct pipe_node *node =3D GET_GLOBAL(keyboard_pipe_node); node; node =3D GET_GLOBALFLAT(node->next)) { + if (GET_GLOBALFLAT(node->pipe)) + return 1; + } + + return 0; } // Handle a ps2 style keyboard command. @@ -390,16 +423,20 @@ usb_check_mouse(void) { if (! CONFIG_USB_MOUSE) return; - struct usb_pipe *pipe =3D GET_GLOBAL(mouse_pipe); - if (!pipe) - return; - for (;;) { - u8 data[MAX_MOUSE_EVENT]; - int ret =3D usb_poll_intr(pipe, data); - if (ret) - break; - handle_mouse((void*)data); + for (struct pipe_node *node =3D GET_GLOBAL(mouse_pipe_node); node; node =3D GET_GLOBALFLAT(node->next)) { + struct usb_pipe *pipe =3D GET_GLOBALFLAT(node->pipe); + + if (!pipe) + continue; + + for (;;) { + u8 data[MAX_MOUSE_EVENT]; + int ret =3D usb_poll_intr(pipe, data); + if (ret) + break; + handle_mouse((void*)data); + } } } @@ -409,7 +446,13 @@ usb_mouse_active(void) { if (! CONFIG_USB_MOUSE) return 0; - return GET_GLOBAL(mouse_pipe) !=3D NULL; + + for (struct pipe_node *node =3D GET_GLOBAL(mouse_pipe_node); node; node =3D GET_GLOBALFLAT(node->next)) { + if (GET_GLOBALFLAT(node->pipe)) + return 1; + } + + return 0; } // Handle a ps2 style mouse command. --=20 2.46.0 On Sun, Oct 27, 2024 at 8:53=E2=80=AFAM Daniel Khodabakhsh wrote: > > From 354935deae7cb79ee9a400222ed950314694194a Mon Sep 17 00:00:00 2001 > From: Daniel Khodabakhsh > Date: Sat, 26 Oct 2024 04:18:49 -0700 > Subject: [PATCH] Support multiple USB HID devices by storing them in a li= nked > list. > > --- > src/hw/usb-hid.c | 108 +++++++++++++++++++++++++++++++++-------------- > 1 file changed, 77 insertions(+), 31 deletions(-) > > diff --git a/src/hw/usb-hid.c b/src/hw/usb-hid.c > index dec198ac..b7d5533e 100644 > --- a/src/hw/usb-hid.c > +++ b/src/hw/usb-hid.c > @@ -1,20 +1,44 @@ > // Code for handling USB Human Interface Devices (HID). > // > // Copyright (C) 2009 Kevin O'Connor > +// Copyright (C) 2024 Daniel Khodabakhsh > // > // This file may be distributed under the terms of the GNU LGPLv3 licens= e. > > #include "biosvar.h" // GET_GLOBAL > #include "config.h" // CONFIG_* > -#include "output.h" // dprintf > +#include "output.h" // dprintf, warn_noalloc > +#include "malloc.h" // malloc_fseg > #include "ps2port.h" // ATKBD_CMD_GETID > +#include "stacks.h" // mutex_lock, mutex_unlock > #include "usb.h" // usb_ctrlrequest > #include "usb-hid.h" // usb_keyboard_setup > #include "util.h" // process_key > > -struct usb_pipe *keyboard_pipe VARFSEG; > -struct usb_pipe *mouse_pipe VARFSEG; > +struct pipe_node { > + struct usb_pipe *pipe; > + struct pipe_node *next; > +}; > + > +struct mutex_s usb_hid_lock; > + > +struct pipe_node *keyboard_pipe_node VARFSEG =3D NULL; > +struct pipe_node *mouse_pipe_node VARFSEG =3D NULL; > > +static struct pipe_node* > +add_pipe_node(struct pipe_node *old_root_node, struct usb_pipe *pipe) > +{ > + struct pipe_node *new_root_node =3D malloc_fseg(sizeof(struct pipe_n= ode)); > + if (!new_root_node) { > + warn_noalloc(); > + return old_root_node; > + } > + > + new_root_node->pipe =3D pipe; > + new_root_node->next =3D old_root_node; > + > + return new_root_node; > +} > > /**************************************************************** > * Setup > @@ -64,9 +88,6 @@ usb_kbd_setup(struct usbdevice_s *usbdev > { > if (! CONFIG_USB_KEYBOARD) > return -1; > - if (keyboard_pipe) > - // XXX - this enables the first found keyboard (could be random) > - return -1; > > if (epdesc->wMaxPacketSize < sizeof(struct keyevent) > || epdesc->wMaxPacketSize > MAX_KBD_EVENT) { > @@ -87,10 +108,14 @@ usb_kbd_setup(struct usbdevice_s *usbdev > if (ret) > dprintf(3, "Warning: Failed to set key repeat rate\n"); > > - keyboard_pipe =3D usb_alloc_pipe(usbdev, epdesc); > + struct usb_pipe *keyboard_pipe =3D usb_alloc_pipe(usbdev, epdesc); > if (!keyboard_pipe) > return -1; > > + mutex_lock(&usb_hid_lock); > + keyboard_pipe_node =3D add_pipe_node(keyboard_pipe_node, keyboard_pi= pe); > + mutex_unlock(&usb_hid_lock); > + > dprintf(1, "USB keyboard initialized\n"); > return 0; > } > @@ -109,9 +134,6 @@ usb_mouse_setup(struct usbdevice_s *usbdev > { > if (! CONFIG_USB_MOUSE) > return -1; > - if (mouse_pipe) > - // XXX - this enables the first found mouse (could be random) > - return -1; > > if (epdesc->wMaxPacketSize < sizeof(struct mouseevent) > || epdesc->wMaxPacketSize > MAX_MOUSE_EVENT) { > @@ -125,10 +147,14 @@ usb_mouse_setup(struct usbdevice_s *usbdev > if (ret) > return -1; > > - mouse_pipe =3D usb_alloc_pipe(usbdev, epdesc); > + struct usb_pipe *mouse_pipe =3D usb_alloc_pipe(usbdev, epdesc); > if (!mouse_pipe) > return -1; > > + mutex_lock(&usb_hid_lock); > + mouse_pipe_node =3D add_pipe_node(mouse_pipe_node, mouse_pipe); > + mutex_unlock(&usb_hid_lock); > + > dprintf(1, "USB mouse initialized\n"); > return 0; > } > @@ -325,16 +351,20 @@ usb_check_key(void) > { > if (! CONFIG_USB_KEYBOARD) > return; > - struct usb_pipe *pipe =3D GET_GLOBAL(keyboard_pipe); > - if (!pipe) > - return; > > - for (;;) { > - u8 data[MAX_KBD_EVENT]; > - int ret =3D usb_poll_intr(pipe, data); > - if (ret) > - break; > - handle_key((void*)data); > + for (struct pipe_node *node =3D GET_GLOBAL(keyboard_pipe_node); > node; node =3D GET_GLOBALFLAT(node->next)) { > + struct usb_pipe *pipe =3D GET_GLOBALFLAT(node->pipe); > + > + if (!pipe) > + continue; > + > + for (;;) { > + u8 data[MAX_KBD_EVENT]; > + int ret =3D usb_poll_intr(pipe, data); > + if (ret) > + break; > + handle_key((void*)data); > + } > } > } > > @@ -344,7 +374,13 @@ usb_kbd_active(void) > { > if (! CONFIG_USB_KEYBOARD) > return 0; > - return GET_GLOBAL(keyboard_pipe) !=3D NULL; > + > + for (struct pipe_node *node =3D GET_GLOBAL(keyboard_pipe_node); > node; node =3D GET_GLOBALFLAT(node->next)) { > + if (GET_GLOBALFLAT(node->pipe)) > + return 1; > + } > + > + return 0; > } > > // Handle a ps2 style keyboard command. > @@ -390,16 +426,20 @@ usb_check_mouse(void) > { > if (! CONFIG_USB_MOUSE) > return; > - struct usb_pipe *pipe =3D GET_GLOBAL(mouse_pipe); > - if (!pipe) > - return; > > - for (;;) { > - u8 data[MAX_MOUSE_EVENT]; > - int ret =3D usb_poll_intr(pipe, data); > - if (ret) > - break; > - handle_mouse((void*)data); > + for (struct pipe_node *node =3D GET_GLOBAL(mouse_pipe_node); node; > node =3D GET_GLOBALFLAT(node->next)) { > + struct usb_pipe *pipe =3D GET_GLOBALFLAT(node->pipe); > + > + if (!pipe) > + continue; > + > + for (;;) { > + u8 data[MAX_MOUSE_EVENT]; > + int ret =3D usb_poll_intr(pipe, data); > + if (ret) > + break; > + handle_mouse((void*)data); > + } > } > } > > @@ -409,7 +449,13 @@ usb_mouse_active(void) > { > if (! CONFIG_USB_MOUSE) > return 0; > - return GET_GLOBAL(mouse_pipe) !=3D NULL; > + > + for (struct pipe_node *node =3D GET_GLOBAL(mouse_pipe_node); node; > node =3D GET_GLOBALFLAT(node->next)) { > + if (GET_GLOBALFLAT(node->pipe)) > + return 1; > + } > + > + return 0; > } > > // Handle a ps2 style mouse command. > -- > 2.46.0 > > > On Sun, Oct 27, 2024 at 1:46=E2=80=AFAM Daniel Khodabakhsh > wrote: > > > > This change allows the use of multiple USB HID keyboards and mice. > > It's similar to the change by Stef van Os from this thread: > > > > https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/thread/O6= Y4LUKPFZLNBBJUGKB6MUHG4LPCP3KB/ > > > > however this new change uses the linked list approach instead of a fixe= d array. > > > > Tested on QEMU and an Asus KGPE-D16 with 2 keyboards and one mice --0000000000009d94fa0626594331 Content-Type: application/octet-stream; name="0001-Support-multiple-USB-HID-devices.patch" Content-Disposition: attachment; filename="0001-Support-multiple-USB-HID-devices.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_m37tfqm60 RnJvbSBmNmE2NTNiMGZjYWMwMzU5ZDU5OGMzNDJlZDBhNTFiMDVkNmViZTE2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBEYW5pZWwgS2hvZGFiYWtoc2ggPGQua2hvZGFiYWtoc2hAZ21h aWwuY29tPgpEYXRlOiBUaHUsIDcgTm92IDIwMjQgMTA6MzQ6NDcgLTA4MDAKU3ViamVjdDogW1BB VENIXSBTdXBwb3J0IG11bHRpcGxlIFVTQiBISUQgZGV2aWNlcyBieSBzdG9yaW5nIHRoZW0gaW4g YSBsaW5rZWQKIGxpc3QuCgotLS0KIHNyYy9ody91c2ItaGlkLmMgfCAxMjEgKysrKysrKysrKysr KysrKysrKysrKysrKysrKysrKystLS0tLS0tLS0tLS0tLS0KIDEgZmlsZSBjaGFuZ2VkLCA4MiBp bnNlcnRpb25zKCspLCAzOSBkZWxldGlvbnMoLSkKCmRpZmYgLS1naXQgYS9zcmMvaHcvdXNiLWhp ZC5jIGIvc3JjL2h3L3VzYi1oaWQuYwppbmRleCBkZWMxOThhYy4uMjM1MGUxMjEgMTAwNjQ0Ci0t LSBhL3NyYy9ody91c2ItaGlkLmMKKysrIGIvc3JjL2h3L3VzYi1oaWQuYwpAQCAtMSwyMCArMSw1 NCBAQAogLy8gQ29kZSBmb3IgaGFuZGxpbmcgVVNCIEh1bWFuIEludGVyZmFjZSBEZXZpY2VzIChI SUQpLgogLy8KIC8vIENvcHlyaWdodCAoQykgMjAwOSAgS2V2aW4gTydDb25ub3IgPGtldmluQGtv Y29ubm9yLm5ldD4KKy8vIENvcHlyaWdodCAoQykgMjAyNCAgRGFuaWVsIEtob2RhYmFraHNoIDxk Lmtob2RhYmFraHNoQGdtYWlsLmNvbT4KIC8vCiAvLyBUaGlzIGZpbGUgbWF5IGJlIGRpc3RyaWJ1 dGVkIHVuZGVyIHRoZSB0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VzYmRldmljZV9zICp1c2JkZXYKKyAgICAgICAgICAgICAg LCBzdHJ1Y3QgdXNiX2VuZHBvaW50X2Rlc2NyaXB0b3IgKmVwZGVzYykKK3sKKyAgICBzdHJ1Y3Qg dXNiX3BpcGUgKnBpcGUgPSB1c2JfYWxsb2NfcGlwZSh1c2JkZXYsIGVwZGVzYyk7CisgICAgaWYg KCFwaXBlKQorICAgICAgICByZXR1cm4gLTE7CisKKyAgICBzdHJ1Y3QgcGlwZV9ub2RlICpuZXdf cm9vdF9ub2RlID0gbWFsbG9jX2ZzZWcoc2l6ZW9mKHN0cnVjdCBwaXBlX25vZGUpKTsKKyAgICBp ZiAoIW5ld19yb290X25vZGUpIHsKKyAgICAgICAgd2Fybl9ub2FsbG9jKCk7CisgICAgICAgIHJl dHVybiAtMTsKKyAgICB9CisKKyAgICBuZXdfcm9vdF9ub2RlLT5waXBlID0gcGlwZTsKKworICAg IG11dGV4X2xvY2soJnVzYl9oaWRfbG9jayk7CisgICAgbmV3X3Jvb3Rfbm9kZS0+bmV4dCA9ICpy b290X25vZGU7CisgICAgKnJvb3Rfbm9kZSA9IG5ld19yb290X25vZGU7CisgICAgbXV0ZXhfdW5s b2NrKCZ1c2JfaGlkX2xvY2spOworCisgICAgcmV0dXJuIDA7Cit9CiAKIC8qKioqKioqKioqKioq KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAgKiBT ZXR1cApAQCAtNjQsOSArOTgsNiBAQCB1c2Jfa2JkX3NldHVwKHN0cnVjdCB1c2JkZXZpY2VfcyAq dXNiZGV2CiB7CiAgICAgaWYgKCEgQ09ORklHX1VTQl9LRVlCT0FSRCkKICAgICAgICAgcmV0dXJu IC0xOwotICAgIGlmIChrZXlib2FyZF9waXBlKQotICAgICAgICAvLyBYWFggLSB0aGlzIGVuYWJs ZXMgdGhlIGZpcnN0IGZvdW5kIGtleWJvYXJkIChjb3VsZCBiZSByYW5kb20pCi0gICAgICAgIHJl dH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XQpCisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBo YW5kbGVfa2V5KCh2b2lkKilkYXRhKTsKKyAgICAgICAgfQogICAgIH0KIH0KIApAQCAtMzQ0LDcg KzM3MSwxMyBAQCB1c2Jfa2JkX2FjdGl2ZSh2b2lkKQogewogICAgIGlmICghIENPTkZJR19VU0Jf S0VZQk9BUkQpCiAgICAgICAgIHJldHVybiAwOwotICAgIHJldHVybiBHRVRfR0xPQkFMKGtleWJv YXJkX3BpcGUpICE9IE5VTEw7CisKKyAgICBmb3IgKHN0cnVjdCBwaXBlX25vZGUgKm5vZGUgPSBH RVRfR0xPQkFMKGtleWJvYXJkX3BpcGVfbm9kZSk7IG5vZGU7IG5vZGUgPSBHRVRfR0xPQkFMRkxB VChub2RlLT5uZXh0KSkgeworICAgICAgICBpZiAoR0VUX0dMT0JBTEZMQVQobm9kZS0+cGlwZSkp CisgICAgICAgICAgICByZXR1cm4gMTsKKyAgICB9CisKKyAgICByZXR1cm4gMDsKIH0KIAogLy8g SGFuZGxlIGEgcHMyIHN0eWxlIGtleWJvYXJkIGNvbW1hbmQuCkBAIC0zOTAsMTYgKzQyMywyMCBA QCB1c2JfY2hlY2tfbW91c2Uodm9pZCkKIHsKICAgICBpZiAoISBDT05GSUdfVVNCX01PVVNFKQog ICAgICAgICByZXR1cm47Ci0gICAgc3RydWN0IHVzYl9waXBlICpwaXBlID0gR0VUX0dMT0JBTCht b3VzZV9waXBlKTsKLSAgICBpZiAoIXBpcGUpCi0gICAgICAgIHJldHVybjsKIAotICAgIGZvciAo OzspIHsKLSAgICAgICAgdTggZGF0YVtNQVhfTU9VU0VfRVZFTlRdOwotICAgICAgICBpbnQgcmV0 ID0gdXNiX3BvbGxfaW50cihwaXBlLCBkYXRhKTsKLSAgICAgICAgaWYgKHJldCkKLSAgICAgICAg ICAgIGJyZWFrOwotICAgICAgICBoYW5kbGVfbW91c2UoKHZvaWQqKWRhdGEpOworICAgIGZvciAo c3RydWN0IHBpcGVfbm9kZSAqbm9kZSA9IEdFVF9HTE9CQUwobW91c2VfcGlwZV9ub2RlKTsgbm9k ZTsgbm9kZSA9IEdFVF9HTE9CQUxGTEFUKG5vZGUtPm5leHQpKSB7CisgICAgICAgIHN0cnVjdCB1 c2JfcGlwZSAqcGlwZSA9IEdFVF9HTE9CQUxGTEFUKG5vZGUtPnBpcGUpOworCisgICAgICAgIGlm ICghcGlwZSkKKyAgICAgICAgICAgIGNvbnRpbnVlOworCisgICAgICAgIGZvciAoOzspIHsKKyAg ICAgICAgICAgIHU4IGRhdGFbTUFYX01PVVNFX0VWRU5UXTsKKyAgICAgICAgICAgIGludCByZXQg PSB1c2JfcG9sbF9pbnRyKHBpcGUsIGRhdGEpOworICAgICAgICAgICAgaWYgKHJldCkKKyAgICAg ICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGhhbmRsZV9tb3VzZSgodm9pZCopZGF0YSk7 CisgICAgICAgIH0KICAgICB9CiB9CiAKQEAgLTQwOSw3ICs0NDYsMTMgQEAgdXNiX21vdXNlX2Fj dGl2ZSh2b2lkKQogewogICAgIGlmICghIENPTkZJR19VU0JfTU9VU0UpCiAgICAgICAgIHJldHVy biAwOwotICAgIHJldHVybiBHRVRfR0xPQkFMKG1vdXNlX3BpcGUpICE9IE5VTEw7CisKKyAgICBm b3IgKHN0cnVjdCBwaXBlX25vZGUgKm5vZGUgPSBHRVRfR0xPQkFMKG1vdXNlX3BpcGVfbm9kZSk7 IG5vZGU7IG5vZGUgPSBHRVRfR0xPQkFMRkxBVChub2RlLT5uZXh0KSkgeworICAgICAgICBpZiAo R0VUX0dMT0JBTEZMQVQobm9kZS0+cGlwZSkpCisgICAgICAgICAgICByZXR1cm4gMTsKKyAgICB9 CisKKyAgICByZXR1cm4gMDsKIH0KIAogLy8gSGFuZGxlIGEgcHMyIHN0eWxlIG1vdXNlIGNvbW1h bmQuCi0tIAoyLjQ2LjAKCg== --0000000000009d94fa0626594331 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org --0000000000009d94fa0626594331--