From patchwork Mon Jun 20 07:38:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66BDBCCA480 for ; Mon, 20 Jun 2022 07:38:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352533.579369 (Exim 4.92) (envelope-from ) id 1o3Bze-0003oU-Ko; Mon, 20 Jun 2022 07:38:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352533.579369; Mon, 20 Jun 2022 07:38:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bze-0003o4-6C; Mon, 20 Jun 2022 07:38:42 +0000 Received: by outflank-mailman (input) for mailman id 352533; Mon, 20 Jun 2022 07:38:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzc-0002ZD-Bd for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:40 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fc0b9888-f06b-11ec-b725-ed86ccbb4733; Mon, 20 Jun 2022 09:38:33 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0014521BB8; Mon, 20 Jun 2022 07:38:32 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C6946134CA; Mon, 20 Jun 2022 07:38:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IP0rL/gjsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:32 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fc0b9888-f06b-11ec-b725-ed86ccbb4733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qUmUwfIlKzy4uayyFfnh4ZN+f1gTP+njO8tkwccWoP4=; b=MAKOBlsmDx/DpF2gfo0e6hjRB0chjmo+Fm8UcxMU7vC87txTwbnVPqFXpXstAKKwvpkldD b7IAcsjIzqCzfR/z9CJrG7kITaSInvFuo0tp/1bP4wfm7sTOMFAM1FSIEC0317AAUMLMSe +TO+qjXbqxbzUXKCrklkUqixCFUPueo= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 1/8] mini-os: drop xenbus directory Date: Mon, 20 Jun 2022 09:38:13 +0200 Message-Id: <20220620073820.9336-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 The xenbus directory contains only a single source. Move this source up and remove the xenbus directory. Signed-off-by: Juergen Gross --- Makefile | 3 +-- xenbus/xenbus.c => xenbus.c | 0 2 files changed, 1 insertion(+), 2 deletions(-) rename xenbus/xenbus.c => xenbus.c (100%) diff --git a/Makefile b/Makefile index 9f95d197..16d1f5d6 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ src-y += sched.c src-y += shutdown.c src-$(CONFIG_TEST) += test.c src-$(CONFIG_BALLOON) += balloon.c +src-$(CONFIG_XENBUS) += xenbus.c src-y += lib/ctype.c src-y += lib/math.c @@ -67,8 +68,6 @@ src-y += lib/sys.c src-y += lib/xmalloc.c src-$(CONFIG_LIBXS) += lib/xs.c -src-$(CONFIG_XENBUS) += xenbus/xenbus.c - src-y += console/console.c src-y += console/xencons_ring.c src-$(CONFIG_CONSFRONT) += console/xenbus.c diff --git a/xenbus/xenbus.c b/xenbus.c similarity index 100% rename from xenbus/xenbus.c rename to xenbus.c From patchwork Mon Jun 20 07:38:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4C8AC433EF for ; Mon, 20 Jun 2022 07:38:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352538.579393 (Exim 4.92) (envelope-from ) id 1o3Bzh-0004LK-Hd; Mon, 20 Jun 2022 07:38:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352538.579393; Mon, 20 Jun 2022 07:38:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzh-0004K1-5F; Mon, 20 Jun 2022 07:38:45 +0000 Received: by outflank-mailman (input) for mailman id 352538; Mon, 20 Jun 2022 07:38:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bze-0002ZE-KT for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:42 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fc822beb-f06b-11ec-bd2d-47488cf2e6aa; Mon, 20 Jun 2022 09:38:34 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4217C21BC8; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 09A63134CA; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mPnvAPkjsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:33 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fc822beb-f06b-11ec-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgB6fTgQL43gcxc48HlbOD3FwW8e0Wc8cOsNTfGA2fM=; b=pFYN5R+LFVNfPmEVSqYvHvqQvriSnnGqsviLHmWLZN+qbOrSZmjz5jINkVb2suyJKZcFXs T5H17S/1T20lJ1HvSBtEMJLpaUw9kQpJ+694TjSPAMvGxs7+QMLRr6wWvX9FRJTLfon+eD i/XDrNOXTMWFH7sHC3hsj4X3ZoJ3p2o= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 2/8] mini-os: apply coding style to xenbus.c Date: Mon, 20 Jun 2022 09:38:14 +0200 Message-Id: <20220620073820.9336-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 Make xenbus.c coding style compliant. Signed-off-by: Juergen Gross --- xenbus.c | 510 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 303 insertions(+), 207 deletions(-) diff --git a/xenbus.c b/xenbus.c index b687678f..aa1fe7bf 100644 --- a/xenbus.c +++ b/xenbus.c @@ -1,15 +1,15 @@ -/* +/* **************************************************************************** * (C) 2006 - Cambridge University **************************************************************************** * * File: xenbus.c - * Author: Steven Smith (sos22@cam.ac.uk) + * Author: Steven Smith (sos22@cam.ac.uk) * Changes: Grzegorz Milos (gm281@cam.ac.uk) * Changes: John D. Ramsdell - * + * * Date: Jun 2006, chages Aug 2005 - * + * * Environment: Xen Minimal OS * Description: Minimal implementation of xenbus * @@ -32,10 +32,10 @@ #include #define min(x,y) ({ \ - typeof(x) tmpx = (x); \ - typeof(y) tmpy = (y); \ - tmpx < tmpy ? tmpx : tmpy; \ - }) + typeof(x) tmpx = (x); \ + typeof(y) tmpy = (y); \ + tmpx < tmpy ? tmpx : tmpy; \ + }) #ifdef XENBUS_DEBUG #define DEBUG(_f, _a...) \ @@ -56,7 +56,8 @@ static struct watch { xenbus_event_queue *events; struct watch *next; } *watches; -struct xenbus_req_info + +struct xenbus_req_info { int in_use:1; struct wait_queue_head waitq; @@ -93,14 +94,12 @@ void get_xenbus(void *p) } #endif -static void memcpy_from_ring(const void *Ring, - void *Dest, - int off, - int len) +static void memcpy_from_ring(const void *Ring, void *Dest, int off, int len) { int c1, c2; const char *ring = Ring; char *dest = Dest; + c1 = min(len, XENSTORE_RING_SIZE - off); c2 = len - c1; memcpy(dest, ring + off, c1); @@ -111,24 +110,28 @@ char **xenbus_wait_for_watch_return(xenbus_event_queue *queue) { struct xenbus_event *event; DEFINE_WAIT(w); - if (!queue) + + if ( !queue ) queue = &xenbus_events; - while (!(event = *queue)) { + while ( !(event = *queue) ) + { add_waiter(w, xenbus_watch_queue); schedule(); } remove_waiter(w, xenbus_watch_queue); *queue = event->next; + return &event->path; } void xenbus_wait_for_watch(xenbus_event_queue *queue) { char **ret; - if (!queue) + + if ( !queue ) queue = &xenbus_events; ret = xenbus_wait_for_watch_return(queue); - if (ret) + if ( ret ) free(ret); else printk("unexpected path returned by watch\n"); @@ -137,33 +140,39 @@ void xenbus_wait_for_watch(xenbus_event_queue *queue) void xenbus_release_wait_for_watch(xenbus_event_queue *queue) { struct xenbus_event *event = malloc(sizeof(*event)); + event->next = *queue; *queue = event; wake_up(&xenbus_watch_queue); } -char* xenbus_wait_for_value(const char* path, const char* value, xenbus_event_queue *queue) +char *xenbus_wait_for_value(const char *path, const char *value, + xenbus_event_queue *queue) { - if (!queue) + if ( !queue ) queue = &xenbus_events; - for(;;) + + for( ;; ) { char *res, *msg; int r; msg = xenbus_read(XBT_NIL, path, &res); - if(msg) return msg; + if ( msg ) + return msg; r = strcmp(value,res); free(res); - if(r==0) break; - else xenbus_wait_for_watch(queue); + if ( r==0 ) + return NULL; + + xenbus_wait_for_watch(queue); } - return NULL; } -char *xenbus_switch_state(xenbus_transaction_t xbt, const char* path, XenbusState state) +char *xenbus_switch_state(xenbus_transaction_t xbt, const char *path, + XenbusState state) { char *current_state; char *msg = NULL; @@ -174,18 +183,22 @@ char *xenbus_switch_state(xenbus_transaction_t xbt, const char* path, XenbusStat int retry = 0; do { - if (xbt == XBT_NIL) { + if ( xbt == XBT_NIL ) + { msg = xenbus_transaction_start(&xbt); - if (msg) goto exit; + if ( msg ) + goto exit; xbt_flag = 1; } msg = xenbus_read(xbt, path, ¤t_state); - if (msg) goto exit; + if ( msg ) + goto exit; rs = (XenbusState) (current_state[0] - '0'); free(current_state); - if (rs == state) { + if ( rs == state ) + { msg = NULL; goto exit; } @@ -194,37 +207,42 @@ char *xenbus_switch_state(xenbus_transaction_t xbt, const char* path, XenbusStat msg = xenbus_write(xbt, path, value); exit: - if (xbt_flag) { + if ( xbt_flag ) + { msg2 = xenbus_transaction_end(xbt, 0, &retry); xbt = XBT_NIL; } - if (msg == NULL && msg2 != NULL) + if ( msg == NULL && msg2 != NULL ) msg = msg2; else free(msg2); - } while (retry); + } while ( retry ); return msg; } -char *xenbus_wait_for_state_change(const char* path, XenbusState *state, xenbus_event_queue *queue) +char *xenbus_wait_for_state_change(const char *path, XenbusState *state, + xenbus_event_queue *queue) { - if (!queue) + if ( !queue ) queue = &xenbus_events; - for(;;) + + for( ;; ) { char *res, *msg; XenbusState rs; msg = xenbus_read(XBT_NIL, path, &res); - if(msg) return msg; + if ( msg ) + return msg; - rs = (XenbusState) (res[0] - 48); + rs = (XenbusState)(res[0] - 48); free(res); - if (rs == *state) + if ( rs == *state ) xenbus_wait_for_watch(queue); - else { + else + { *state = rs; break; } @@ -232,14 +250,13 @@ char *xenbus_wait_for_state_change(const char* path, XenbusState *state, xenbus_ return NULL; } - static void xenbus_read_data(char *buf, unsigned int len) { unsigned int off = 0; unsigned int prod, cons; unsigned int size; - while (off != len) + while ( off != len ) { wait_event(xb_waitq, xenstore_buf->rsp_prod != xenstore_buf->rsp_cons); @@ -255,7 +272,7 @@ static void xenbus_read_data(char *buf, unsigned int len) mb(); /* memcpy() and rsp_cons update must not be reordered. */ xenstore_buf->rsp_cons += size; mb(); /* rsp_cons must be visible before we look at rsp_prod. */ - if (xenstore_buf->rsp_prod - cons >= XENSTORE_RING_SIZE) + if ( xenstore_buf->rsp_prod - cons >= XENSTORE_RING_SIZE ) notify_remote_via_evtchn(xenbus_evtchn); } } @@ -265,30 +282,35 @@ static void xenbus_thread_func(void *ign) struct xsd_sockmsg msg; char *data; - for (;;) { + for ( ;; ) + { xenbus_read_data((char *)&msg, sizeof(msg)); DEBUG("Msg len %d, %d avail, id %d.\n", msg.len + sizeof(msg), xenstore_buf->rsp_prod - xenstore_buf->rsp_cons, msg.req_id); - if (msg.len > XENSTORE_PAYLOAD_MAX) { + if ( msg.len > XENSTORE_PAYLOAD_MAX ) + { printk("Xenstore violates protocol, message longer than allowed.\n"); return; } - if (msg.type == XS_WATCH_EVENT) { + if ( msg.type == XS_WATCH_EVENT ) + { struct xenbus_event *event = malloc(sizeof(*event) + msg.len); xenbus_event_queue *events = NULL; struct watch *watch; char *c; int zeroes = 0; - data = (char*)event + sizeof(*event); + data = (char *)event + sizeof(*event); xenbus_read_data(data, msg.len); - for (c = data; c < data + msg.len; c++) - if (!*c) + for ( c = data; c < data + msg.len; c++ ) + if ( !*c ) zeroes++; - if (zeroes != 2) { + + if ( zeroes != 2 ) + { printk("Xenstore: illegal watch event data\n"); free(event); continue; @@ -297,17 +319,21 @@ static void xenbus_thread_func(void *ign) event->path = data; event->token = event->path + strlen(event->path) + 1; - for (watch = watches; watch; watch = watch->next) - if (!strcmp(watch->token, event->token)) { + for ( watch = watches; watch; watch = watch->next ) + if ( !strcmp(watch->token, event->token) ) + { events = watch->events; break; } - if (events) { + if ( events ) + { event->next = *events; *events = event; wake_up(&xenbus_watch_queue); - } else { + } + else + { printk("Xenstore: unexpected watch token %s\n", event->token); free(event); } @@ -319,7 +345,8 @@ static void xenbus_thread_func(void *ign) memcpy(data, &msg, sizeof(msg)); xenbus_read_data(data + sizeof(msg), msg.len); - if (msg.req_id >= NR_REQS || !req_info[msg.req_id].in_use) { + if ( msg.req_id >= NR_REQS || !req_info[msg.req_id].in_use ) + { printk("Xenstore: illegal request id %d\n", msg.req_id); free(data); continue; @@ -334,7 +361,7 @@ static void xenbus_thread_func(void *ign) } static void xenbus_evtchn_handler(evtchn_port_t port, struct pt_regs *regs, - void *ign) + void *ign) { wake_up(&xb_waitq); } @@ -347,12 +374,15 @@ static DECLARE_WAIT_QUEUE_HEAD(req_wq); static void release_xenbus_id(int id) { BUG_ON(!req_info[id].in_use); + spin_lock(&req_lock); + req_info[id].in_use = 0; nr_live_reqs--; req_info[id].in_use = 0; - if (nr_live_reqs == 0 || nr_live_reqs == NR_REQS - 1) + if ( nr_live_reqs == 0 || nr_live_reqs == NR_REQS - 1 ) wake_up(&req_wq); + spin_unlock(&req_lock); } @@ -363,27 +393,27 @@ static int allocate_xenbus_id(void) static int probe; int o_probe; - while (1) + while ( 1 ) { spin_lock(&req_lock); - if (nr_live_reqs < NR_REQS) + if ( nr_live_reqs < NR_REQS ) break; spin_unlock(&req_lock); - wait_event(req_wq, (nr_live_reqs < NR_REQS)); + wait_event(req_wq, nr_live_reqs < NR_REQS); } o_probe = probe; - for (;;) + while ( req_info[o_probe].in_use ) { - if (!req_info[o_probe].in_use) - break; o_probe = (o_probe + 1) % NR_REQS; BUG_ON(o_probe == probe); } nr_live_reqs++; req_info[o_probe].in_use = 1; probe = (o_probe + 1) % NR_REQS; + spin_unlock(&req_lock); + init_waitqueue_head(&req_info[o_probe].waitq); return o_probe; @@ -393,6 +423,7 @@ static int allocate_xenbus_id(void) void init_xenbus(void) { int err; + DEBUG("init_xenbus called.\n"); create_thread("xenstore", xenbus_thread_func, NULL); DEBUG("buf at %p.\n", xenstore_buf); @@ -408,13 +439,13 @@ void fini_xenbus(void) void suspend_xenbus(void) { /* Check for live requests and wait until they finish */ - while (1) + while ( 1 ) { spin_lock(&req_lock); - if (nr_live_reqs == 0) + if ( nr_live_reqs == 0 ) break; spin_unlock(&req_lock); - wait_event(req_wq, (nr_live_reqs == 0)); + wait_event(req_wq, nr_live_reqs == 0); } mask_evtchn(xenbus_evtchn); @@ -436,8 +467,10 @@ void resume_xenbus(int canceled) #endif unmask_evtchn(xenbus_evtchn); - if (!canceled) { - for (watch = watches; watch; watch = watch->next) { + if ( !canceled ) + { + for ( watch = watches; watch; watch = watch->next ) + { req[0].data = watch->path; req[0].len = strlen(watch->path) + 1; req[1].data = watch->token; @@ -445,10 +478,12 @@ void resume_xenbus(int canceled) rep = xenbus_msg_reply(XS_WATCH, XBT_NIL, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) { + if ( msg ) + { xprintk("error on XS_WATCH: %s\n", msg); free(msg); - } else + } + else free(rep); } } @@ -456,12 +491,14 @@ void resume_xenbus(int canceled) notify_remote_via_evtchn(xenbus_evtchn); } -/* Send data to xenbus. This can block. All of the requests are seen - by xenbus as if sent atomically. The header is added - automatically, using type %type, req_id %req_id, and trans_id - %trans_id. */ +/* + * Send data to xenbus. This can block. All of the requests are seen + * by xenbus as if sent atomically. The header is added + * automatically, using type %type, req_id %req_id, and trans_id + * %trans_id. + */ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id, - const struct write_req *req, int nr_reqs) + const struct write_req *req, int nr_reqs) { XENSTORE_RING_IDX prod; int r; @@ -470,12 +507,12 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id, int req_off; int total_off; int this_chunk; - struct xsd_sockmsg m = {.type = type, .req_id = req_id, - .tx_id = trans_id }; + struct xsd_sockmsg m = {.type = type, .req_id = req_id, .tx_id = trans_id }; struct write_req header_req = { &m, sizeof(m) }; - for (r = 0; r < nr_reqs; r++) + for ( r = 0; r < nr_reqs; r++ ) len += req[r].len; + m.len = len; len += sizeof(m); @@ -489,10 +526,10 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id, /* Send the message in chunks using free ring space when available. */ total_off = 0; req_off = 0; - while (total_off < len) + while ( total_off < len ) { prod = xenstore_buf->req_prod; - if (prod - xenstore_buf->req_cons >= XENSTORE_RING_SIZE) + if ( prod - xenstore_buf->req_cons >= XENSTORE_RING_SIZE ) { /* Send evtchn to notify remote */ notify_remote_via_evtchn(xenbus_evtchn); @@ -514,10 +551,10 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id, prod += this_chunk; req_off += this_chunk; total_off += this_chunk; - if (req_off == cur_req->len) + if ( req_off == cur_req->len ) { req_off = 0; - if (cur_req == &header_req) + if ( cur_req == &header_req ) cur_req = req; else cur_req++; @@ -538,14 +575,13 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id, up(&xb_write_sem); } -/* Send a mesasge to xenbus, in the same fashion as xb_write, and - block waiting for a reply. The reply is malloced and should be - freed by the caller. */ -struct xsd_sockmsg * -xenbus_msg_reply(int type, - xenbus_transaction_t trans, - struct write_req *io, - int nr_reqs) +/* + * Send a mesasge to xenbus, in the same fashion as xb_write, and + * block waiting for a reply. The reply is malloced and should be + * freed by the caller. + */ +struct xsd_sockmsg *xenbus_msg_reply(int type, xenbus_transaction_t trans, + struct write_req *io, int nr_reqs) { int id; DEFINE_WAIT(w); @@ -563,29 +599,36 @@ xenbus_msg_reply(int type, rep = req_info[id].reply; BUG_ON(rep->req_id != id); release_xenbus_id(id); + return rep; } static char *errmsg(struct xsd_sockmsg *rep) { char *res; - if (!rep) { - char msg[] = "No reply"; - size_t len = strlen(msg) + 1; - return memcpy(malloc(len), msg, len); + + if ( !rep ) + { + char msg[] = "No reply"; + size_t len = strlen(msg) + 1; + return memcpy(malloc(len), msg, len); } - if (rep->type != XS_ERROR) - return NULL; + if ( rep->type != XS_ERROR ) + return NULL; + res = malloc(rep->len + 1); memcpy(res, rep + 1, rep->len); res[rep->len] = 0; free(rep); + return res; } -/* List the contents of a directory. Returns a malloc()ed array of - pointers to malloc()ed strings. The array is NULL terminated. May - block. */ +/* + * List the contents of a directory. Returns a malloc()ed array of + * pointers to malloc()ed strings. The array is NULL terminated. May + * block. + */ char *xenbus_ls(xenbus_transaction_t xbt, const char *pre, char ***contents) { struct xsd_sockmsg *reply, *repmsg; @@ -595,23 +638,30 @@ char *xenbus_ls(xenbus_transaction_t xbt, const char *pre, char ***contents) repmsg = xenbus_msg_reply(XS_DIRECTORY, xbt, req, ARRAY_SIZE(req)); msg = errmsg(repmsg); - if (msg) { - *contents = NULL; - return msg; + if ( msg ) + { + *contents = NULL; + return msg; } + reply = repmsg + 1; - for (x = nr_elems = 0; x < repmsg->len; x++) + for ( x = nr_elems = 0; x < repmsg->len; x++ ) nr_elems += (((char *)reply)[x] == 0); + res = malloc(sizeof(res[0]) * (nr_elems + 1)); - for (x = i = 0; i < nr_elems; i++) { + for ( x = i = 0; i < nr_elems; i++ ) + { int l = strlen((char *)reply + x); + res[i] = malloc(l + 1); memcpy(res[i], (char *)reply + x, l + 1); x += l + 1; } + res[i] = NULL; free(repmsg); *contents = res; + return NULL; } @@ -620,49 +670,56 @@ char *xenbus_read(xenbus_transaction_t xbt, const char *path, char **value) struct write_req req[] = { {path, strlen(path) + 1} }; struct xsd_sockmsg *rep; char *res, *msg; + rep = xenbus_msg_reply(XS_READ, xbt, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) { - *value = NULL; - return msg; + if ( msg ) + { + *value = NULL; + return msg; } + res = malloc(rep->len + 1); memcpy(res, rep + 1, rep->len); res[rep->len] = 0; free(rep); *value = res; + return NULL; } -char *xenbus_write(xenbus_transaction_t xbt, const char *path, const char *value) +char *xenbus_write(xenbus_transaction_t xbt, const char *path, + const char *value) { - struct write_req req[] = { - {path, strlen(path) + 1}, - {value, strlen(value)}, + struct write_req req[] = { + {path, strlen(path) + 1}, + {value, strlen(value)}, }; struct xsd_sockmsg *rep; char *msg; + rep = xenbus_msg_reply(XS_WRITE, xbt, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) return msg; + if ( msg ) + return msg; + free(rep); + return NULL; } -char* xenbus_watch_path_token( xenbus_transaction_t xbt, const char *path, const char *token, xenbus_event_queue *events) +char* xenbus_watch_path_token(xenbus_transaction_t xbt, const char *path, + const char *token, xenbus_event_queue *events) { struct xsd_sockmsg *rep; - - struct write_req req[] = { + struct write_req req[] = { {path, strlen(path) + 1}, - {token, strlen(token) + 1}, + {token, strlen(token) + 1}, }; - struct watch *watch = malloc(sizeof(*watch)); - char *msg; - if (!events) + if ( !events ) events = &xenbus_events; watch->token = strdup(token); @@ -674,33 +731,37 @@ char* xenbus_watch_path_token( xenbus_transaction_t xbt, const char *path, const rep = xenbus_msg_reply(XS_WATCH, xbt, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) return msg; + if ( msg ) + return msg; + free(rep); return NULL; } -char* xenbus_unwatch_path_token( xenbus_transaction_t xbt, const char *path, const char *token) +char* xenbus_unwatch_path_token(xenbus_transaction_t xbt, const char *path, + const char *token) { struct xsd_sockmsg *rep; - - struct write_req req[] = { + struct write_req req[] = { {path, strlen(path) + 1}, - {token, strlen(token) + 1}, + {token, strlen(token) + 1}, }; - struct watch *watch, **prev; - char *msg; rep = xenbus_msg_reply(XS_UNWATCH, xbt, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) return msg; + if ( msg ) + return msg; + free(rep); - for (prev = &watches, watch = *prev; watch; prev = &watch->next, watch = *prev) - if (!strcmp(watch->token, token)) { + for ( prev = &watches, watch = *prev; watch; + prev = &watch->next, watch = *prev) + if ( !strcmp(watch->token, token) ) + { free(watch->token); free(watch->path); *prev = watch->next; @@ -716,11 +777,14 @@ char *xenbus_rm(xenbus_transaction_t xbt, const char *path) struct write_req req[] = { {path, strlen(path) + 1} }; struct xsd_sockmsg *rep; char *msg; + rep = xenbus_msg_reply(XS_RM, xbt, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) - return msg; + if ( msg ) + return msg; + free(rep); + return NULL; } @@ -729,59 +793,70 @@ char *xenbus_get_perms(xenbus_transaction_t xbt, const char *path, char **value) struct write_req req[] = { {path, strlen(path) + 1} }; struct xsd_sockmsg *rep; char *res, *msg; + rep = xenbus_msg_reply(XS_GET_PERMS, xbt, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) { - *value = NULL; - return msg; + if ( msg ) + { + *value = NULL; + return msg; } + res = malloc(rep->len + 1); memcpy(res, rep + 1, rep->len); res[rep->len] = 0; free(rep); *value = res; + return NULL; } #define PERM_MAX_SIZE 32 -char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, char perm) +char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, + char perm) { char value[PERM_MAX_SIZE]; - struct write_req req[] = { - {path, strlen(path) + 1}, - {value, 0}, + struct write_req req[] = { + {path, strlen(path) + 1}, + {value, 0}, }; struct xsd_sockmsg *rep; char *msg; + snprintf(value, PERM_MAX_SIZE, "%c%hu", perm, dom); req[1].len = strlen(value) + 1; rep = xenbus_msg_reply(XS_SET_PERMS, xbt, req, ARRAY_SIZE(req)); msg = errmsg(rep); - if (msg) - return msg; + if ( msg ) + return msg; + free(rep); + return NULL; } char *xenbus_transaction_start(xenbus_transaction_t *xbt) { - /* xenstored becomes angry if you send a length 0 message, so just - shove a nul terminator on the end */ + /* + * xenstored becomes angry if you send a length 0 message, so just + * shove a nul terminator on the end + */ struct write_req req = { "", 1}; struct xsd_sockmsg *rep; char *err; rep = xenbus_msg_reply(XS_TRANSACTION_START, 0, &req, 1); err = errmsg(rep); - if (err) - return err; + if ( err ) + return err; + sscanf((char *)(rep + 1), "%lu", xbt); free(rep); + return NULL; } -char * -xenbus_transaction_end(xenbus_transaction_t t, int abort, int *retry) +char *xenbus_transaction_end(xenbus_transaction_t t, int abort, int *retry) { struct xsd_sockmsg *rep; struct write_req req; @@ -793,16 +868,19 @@ xenbus_transaction_end(xenbus_transaction_t t, int abort, int *retry) req.len = 2; rep = xenbus_msg_reply(XS_TRANSACTION_END, t, &req, 1); err = errmsg(rep); - if (err) { - if (!strcmp(err, "EAGAIN")) { - *retry = 1; - free(err); - return NULL; - } else { - return err; - } + if ( err ) + { + if ( !strcmp(err, "EAGAIN") ) + { + *retry = 1; + free(err); + return NULL; + } + else + return err; } free(rep); + return NULL; } @@ -812,46 +890,54 @@ int xenbus_read_integer(const char *path) int t; res = xenbus_read(XBT_NIL, path, &buf); - if (res) { - printk("Failed to read %s.\n", path); - free(res); - return -1; + if ( res ) + { + printk("Failed to read %s.\n", path); + free(res); + return -1; } + sscanf(buf, "%d", &t); free(buf); + return t; } -int xenbus_read_uuid(const char* path, unsigned char uuid[16]) { - char * res, *buf; - res = xenbus_read(XBT_NIL, path, &buf); - if(res) { - printk("Failed to read %s.\n", path); - free(res); - return 0; - } - if(strlen(buf) != ((2*16)+4) /* 16 hex bytes and 4 hyphens */ - || sscanf(buf, - "%2hhx%2hhx%2hhx%2hhx-" - "%2hhx%2hhx-" - "%2hhx%2hhx-" - "%2hhx%2hhx-" - "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", - uuid, uuid + 1, uuid + 2, uuid + 3, - uuid + 4, uuid + 5, uuid + 6, uuid + 7, - uuid + 8, uuid + 9, uuid + 10, uuid + 11, - uuid + 12, uuid + 13, uuid + 14, uuid + 15) != 16) { - printk("Xenbus path %s value %s is not a uuid!\n", path, buf); - free(buf); - return 0; - } - free(buf); - return 1; -} - -char* xenbus_printf(xenbus_transaction_t xbt, - const char* node, const char* path, - const char* fmt, ...) +int xenbus_read_uuid(const char *path, unsigned char uuid[16]) +{ + char *res, *buf; + + res = xenbus_read(XBT_NIL, path, &buf); + if ( res ) + { + printk("Failed to read %s.\n", path); + free(res); + return 0; + } + + if ( strlen(buf) != ((2 * 16) + 4) /* 16 hex bytes and 4 hyphens */ || + sscanf(buf, "%2hhx%2hhx%2hhx%2hhx-" + "%2hhx%2hhx-" + "%2hhx%2hhx-" + "%2hhx%2hhx-" + "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", + uuid, uuid + 1, uuid + 2, uuid + 3, + uuid + 4, uuid + 5, uuid + 6, uuid + 7, + uuid + 8, uuid + 9, uuid + 10, uuid + 11, + uuid + 12, uuid + 13, uuid + 14, uuid + 15) != 16) + { + printk("Xenbus path %s value %s is not a uuid!\n", path, buf); + free(buf); + return 0; + } + + free(buf); + + return 1; +} + +char *xenbus_printf(xenbus_transaction_t xbt, const char* node, + const char* path, const char* fmt, ...) { #define BUFFER_SIZE 256 char fullpath[BUFFER_SIZE]; @@ -863,6 +949,7 @@ char* xenbus_printf(xenbus_transaction_t xbt, va_start(args, fmt); vsprintf(val, fmt, args); va_end(args); + return xenbus_write(xbt,fullpath,val); } @@ -890,7 +977,7 @@ static void xenbus_debug_msg(const char *msg) reply = xenbus_msg_reply(XS_DEBUG, 0, req, ARRAY_SIZE(req)); printk("Got a reply, type %d, id %d, len %d.\n", - reply->type, reply->req_id, reply->len); + reply->type, reply->req_id, reply->len); } static void do_ls_test(const char *pre) @@ -900,28 +987,33 @@ static void do_ls_test(const char *pre) printk("ls %s...\n", pre); msg = xenbus_ls(XBT_NIL, pre, &dirs); - if (msg) { - printk("Error in xenbus ls: %s\n", msg); - free(msg); - return; + if ( msg ) + { + printk("Error in xenbus ls: %s\n", msg); + free(msg); + return; } - for (x = 0; dirs[x]; x++) + + for ( x = 0; dirs[x]; x++ ) { printk("ls %s[%d] -> %s\n", pre, x, dirs[x]); free(dirs[x]); } + free(dirs); } static void do_read_test(const char *path) { char *res, *msg; + printk("Read %s...\n", path); msg = xenbus_read(XBT_NIL, path, &res); - if (msg) { - printk("Error in xenbus read: %s\n", msg); - free(msg); - return; + if ( msg ) + { + printk("Error in xenbus read: %s\n", msg); + free(msg); + return; } printk("Read %s -> %s.\n", path, res); free(res); @@ -930,27 +1022,31 @@ static void do_read_test(const char *path) static void do_write_test(const char *path, const char *val) { char *msg; + printk("Write %s to %s...\n", val, path); msg = xenbus_write(XBT_NIL, path, val); - if (msg) { - printk("Result %s\n", msg); - free(msg); - } else { - printk("Success.\n"); + if ( msg ) + { + printk("Result %s\n", msg); + free(msg); } + else + printk("Success.\n"); } static void do_rm_test(const char *path) { char *msg; + printk("rm %s...\n", path); msg = xenbus_rm(XBT_NIL, path); - if (msg) { - printk("Result %s\n", msg); - free(msg); - } else { - printk("Success.\n"); + if ( msg ) + { + printk("Result %s\n", msg); + free(msg); } + else + printk("Success.\n"); } /* Simple testing thing */ From patchwork Mon Jun 20 07:38:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0AB1DC43334 for ; Mon, 20 Jun 2022 07:38:52 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352526.579319 (Exim 4.92) (envelope-from ) id 1o3Bza-0002sx-MX; Mon, 20 Jun 2022 07:38:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352526.579319; Mon, 20 Jun 2022 07:38:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bza-0002sq-J7; Mon, 20 Jun 2022 07:38:38 +0000 Received: by outflank-mailman (input) for mailman id 352526; Mon, 20 Jun 2022 07:38:36 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3BzY-0002ZE-Jq for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:36 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fca02103-f06b-11ec-bd2d-47488cf2e6aa; Mon, 20 Jun 2022 09:38:34 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 758BA21BCC; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 48E2F13A79; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0H4eEPkjsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:33 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fca02103-f06b-11ec-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mXoU4RmuES8ycHpl3QBq4ZigOK3MOzKFqQcwP9Rcli4=; b=QqRprFy/46avRj+XmmN+NOAl8ov8kRK941KMadJFb9N5OhcdNsIwPfT4lZRBj4mv8wOeXD yCLGF+ZwcfA6RIcs0RScMTmzzllsCd+ZkJ+rRr87E7/U9RpLu8RoEiB1Oyko0lWwoF9YfL 0U88RrGFfrwgRAeaagcxsn8Uvuy4QGk= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 3/8] mini-os: eliminate console/console.h Date: Mon, 20 Jun 2022 09:38:15 +0200 Message-Id: <20220620073820.9336-4-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 console/console.h contains only a single prototype. Move that to include/console.h and remove console/console.h. Signed-off-by: Juergen Gross --- console/console.h | 2 -- console/xenbus.c | 2 +- console/xencons_ring.c | 2 +- include/console.h | 1 + 4 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 console/console.h diff --git a/console/console.h b/console/console.h deleted file mode 100644 index e85147a4..00000000 --- a/console/console.h +++ /dev/null @@ -1,2 +0,0 @@ - -void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data); diff --git a/console/xenbus.c b/console/xenbus.c index d8950454..73659656 100644 --- a/console/xenbus.c +++ b/console/xenbus.c @@ -5,13 +5,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include "console.h" void free_consfront(struct consfront_dev *dev) { diff --git a/console/xencons_ring.c b/console/xencons_ring.c index efedf46b..495f0a19 100644 --- a/console/xencons_ring.c +++ b/console/xencons_ring.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -12,7 +13,6 @@ #include #include #include -#include "console.h" DECLARE_WAIT_QUEUE_HEAD(console_queue); diff --git a/include/console.h b/include/console.h index e76e4234..d216d247 100644 --- a/include/console.h +++ b/include/console.h @@ -98,5 +98,6 @@ void free_consfront(struct consfront_dev *dev); extern const struct file_ops console_ops; int open_consfront(char *nodename); #endif +void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data); #endif /* _LIB_CONSOLE_H_ */ From patchwork Mon Jun 20 07:38:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51B4DC433EF for ; Mon, 20 Jun 2022 07:38:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352529.579334 (Exim 4.92) (envelope-from ) id 1o3Bzb-0002xe-FC; Mon, 20 Jun 2022 07:38:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352529.579334; Mon, 20 Jun 2022 07:38:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzb-0002wp-2I; Mon, 20 Jun 2022 07:38:39 +0000 Received: by outflank-mailman (input) for mailman id 352529; Mon, 20 Jun 2022 07:38:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bza-0002ZD-BS for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:38 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fc6d24bb-f06b-11ec-b725-ed86ccbb4733; Mon, 20 Jun 2022 09:38:33 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A9F1A1F383; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7BC73134CA; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aAbZHPkjsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:33 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fc6d24bb-f06b-11ec-b725-ed86ccbb4733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hnPzvgMWe8RIRQajkOAJiVhJlYFwWqqQzJSgyQ7guJk=; b=CzZNsrKQQhGFss+TpjyunC4m5576B69vSH9hfI+3uRjliaCOAI0gFyhtNBlW0XHgOzp7uT 9pRjAc041oQJ5rsL3/RqoCmPvC6Yk3vYPH9beMMJHA6MFgwPxlTxqexwQv/xK6KM67Sf1N IiAm934tudtI2+QIdwABW85FwF0cA6Q= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 4/8] mini-os: rename console/xenbus.c to consfront.c Date: Mon, 20 Jun 2022 09:38:16 +0200 Message-Id: <20220620073820.9336-5-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 Move console/xenbus.c into the main directory and rename it to consfront.c. Signed-off-by: Juergen Gross --- Makefile | 2 +- console/xenbus.c => consfront.c | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename console/xenbus.c => consfront.c (100%) diff --git a/Makefile b/Makefile index 16d1f5d6..509d927b 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ TARGET := mini-os SUBDIRS := lib xenbus console src-$(CONFIG_BLKFRONT) += blkfront.c +src-$(CONFIG_CONSFRONT) += consfront.c src-$(CONFIG_TPMFRONT) += tpmfront.c src-$(CONFIG_TPM_TIS) += tpm_tis.c src-$(CONFIG_TPMBACK) += tpmback.c @@ -70,7 +71,6 @@ src-$(CONFIG_LIBXS) += lib/xs.c src-y += console/console.c src-y += console/xencons_ring.c -src-$(CONFIG_CONSFRONT) += console/xenbus.c # The common mini-os objects to build. APP_OBJS := diff --git a/console/xenbus.c b/consfront.c similarity index 100% rename from console/xenbus.c rename to consfront.c From patchwork Mon Jun 20 07:38:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FD4CC43334 for ; Mon, 20 Jun 2022 07:38:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352537.579389 (Exim 4.92) (envelope-from ) id 1o3Bzg-0004Bm-OS; Mon, 20 Jun 2022 07:38:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352537.579389; Mon, 20 Jun 2022 07:38:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzg-0004Ab-5R; Mon, 20 Jun 2022 07:38:44 +0000 Received: by outflank-mailman (input) for mailman id 352537; Mon, 20 Jun 2022 07:38:42 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bze-0002ZD-CF for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:42 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fc8da548-f06b-11ec-b725-ed86ccbb4733; Mon, 20 Jun 2022 09:38:33 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id DD1BF1F965; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B0F56134CA; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6IjTKfkjsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:33 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fc8da548-f06b-11ec-b725-ed86ccbb4733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f6bMt+f3pFpdaJuWe2kNv32ADnt11PKGb5MGFZlNFfI=; b=VNs992xF2rRY/4TMpQS+AdsE1pIJcmbTPoytwq4AOuNVmc26FTTOceKPDsUytjkrUUe5or xJCnyoidGJMJbREy2Sg6fuYDJKx2nYd5nER40PXa1lL3dItCmAAGwF60c79bNec8yLZAoD k0aoUd+Uj+aBwVu0esc/XZxdkxlsQiA= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 5/8] mini-os: apply coding style to consfront.c Date: Mon, 20 Jun 2022 09:38:17 +0200 Message-Id: <20220620073820.9336-6-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 Make consfront.c coding style compliant. Signed-off-by: Juergen Gross --- consfront.c | 97 +++++++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/consfront.c b/consfront.c index 73659656..dfe6a3f0 100644 --- a/consfront.c +++ b/consfront.c @@ -15,26 +15,30 @@ void free_consfront(struct consfront_dev *dev) { - char* err = NULL; + char *err = NULL; XenbusState state; - char path[strlen(dev->backend) + strlen("/state") + 1]; char nodename[strlen(dev->nodename) + strlen("/state") + 1]; snprintf(path, sizeof(path), "%s/state", dev->backend); snprintf(nodename, sizeof(nodename), "%s/state", dev->nodename); - if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing)) != NULL) { + if ( (err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing)) != + NULL ) + { printk("free_consfront: error changing state to %d: %s\n", XenbusStateClosing, err); goto close; } + state = xenbus_read_integer(path); - while (err == NULL && state < XenbusStateClosing) + while ( err == NULL && state < XenbusStateClosing ) err = xenbus_wait_for_state_change(path, &state, &dev->events); free(err); - if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != NULL) { + if ( (err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != + NULL) + { printk("free_consfront: error changing state to %d: %s\n", XenbusStateClosed, err); goto close; @@ -59,19 +63,22 @@ close: struct consfront_dev *init_consfront(char *_nodename) { xenbus_transaction_t xbt; - char* err = NULL; - char* message=NULL; - int retry=0; - char* msg = NULL; + char *err = NULL; + char *message = NULL; + int retry = 0; + char *msg = NULL; char nodename[256]; char path[256]; + XenbusState state; static int consfrontends = 3; struct consfront_dev *dev; int res; - if (!_nodename) - snprintf(nodename, sizeof(nodename), "device/console/%d", consfrontends); - else { + if ( !_nodename ) + snprintf(nodename, sizeof(nodename), "device/console/%d", + consfrontends); + else + { strncpy(nodename, _nodename, sizeof(nodename) - 1); nodename[sizeof(nodename) - 1] = 0; } @@ -87,13 +94,13 @@ struct consfront_dev *init_consfront(char *_nodename) #endif snprintf(path, sizeof(path), "%s/backend-id", nodename); - if ((res = xenbus_read_integer(path)) < 0) + if ( (res = xenbus_read_integer(path)) < 0 ) goto error; else dev->dom = res; evtchn_alloc_unbound(dev->dom, console_handle_input, dev, &dev->evtchn); - dev->ring = (struct xencons_interface *) alloc_page(); + dev->ring = (struct xencons_interface *)alloc_page(); memset(dev->ring, 0, PAGE_SIZE); dev->ring_ref = gnttab_grant_access(dev->dom, virt_to_mfn(dev->ring), 0); @@ -101,33 +108,36 @@ struct consfront_dev *init_consfront(char *_nodename) again: err = xenbus_transaction_start(&xbt); - if (err) { + if ( err ) + { printk("starting transaction\n"); free(err); } - err = xenbus_printf(xbt, nodename, "ring-ref","%u", - dev->ring_ref); - if (err) { + err = xenbus_printf(xbt, nodename, "ring-ref","%u", dev->ring_ref); + if ( err ) + { message = "writing ring-ref"; goto abort_transaction; } - err = xenbus_printf(xbt, nodename, - "port", "%u", dev->evtchn); - if (err) { + err = xenbus_printf(xbt, nodename, "port", "%u", dev->evtchn); + if ( err ) + { message = "writing event-channel"; goto abort_transaction; } - err = xenbus_printf(xbt, nodename, - "protocol", "%s", XEN_IO_PROTO_ABI_NATIVE); - if (err) { + err = xenbus_printf(xbt, nodename, "protocol", "%s", + XEN_IO_PROTO_ABI_NATIVE); + if ( err ) + { message = "writing protocol"; goto abort_transaction; } snprintf(path, sizeof(path), "%s/state", nodename); err = xenbus_switch_state(xbt, path, XenbusStateConnected); - if (err) { + if ( err ) + { message = "switching state"; goto abort_transaction; } @@ -135,8 +145,9 @@ again: err = xenbus_transaction_end(xbt, 0, &retry); free(err); - if (retry) { - goto again; + if ( retry ) + { + goto again; printk("completing transaction\n"); } @@ -149,31 +160,28 @@ abort_transaction: goto error; done: - snprintf(path, sizeof(path), "%s/backend", nodename); msg = xenbus_read(XBT_NIL, path, &dev->backend); - if (msg) { + if ( msg ) + { printk("Error %s when reading the backend path %s\n", msg, path); goto error; } printk("backend at %s\n", dev->backend); + snprintf(path, sizeof(path), "%s/state", dev->backend); + + free(xenbus_watch_path_token(XBT_NIL, path, path, &dev->events)); + msg = NULL; + state = xenbus_read_integer(path); + while ( msg == NULL && state < XenbusStateConnected ) + msg = xenbus_wait_for_state_change(path, &state, &dev->events); + if ( msg != NULL || state != XenbusStateConnected ) { - XenbusState state; - char path[strlen(dev->backend) + strlen("/state") + 1]; - snprintf(path, sizeof(path), "%s/state", dev->backend); - - free(xenbus_watch_path_token(XBT_NIL, path, path, &dev->events)); - msg = NULL; - state = xenbus_read_integer(path); - while (msg == NULL && state < XenbusStateConnected) - msg = xenbus_wait_for_state_change(path, &state, &dev->events); - if (msg != NULL || state != XenbusStateConnected) { - printk("backend not available, state=%d\n", state); - err = xenbus_unwatch_path_token(XBT_NIL, path, path); - goto error; - } + printk("backend not available, state=%d\n", state); + err = xenbus_unwatch_path_token(XBT_NIL, path, path); + goto error; } unmask_evtchn(dev->evtchn); @@ -190,7 +198,8 @@ error: void fini_consfront(struct consfront_dev *dev) { - if (dev) free_consfront(dev); + if ( dev ) + free_consfront(dev); } #ifdef HAVE_LIBC From patchwork Mon Jun 20 07:38:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 30D7DC43334 for ; Mon, 20 Jun 2022 07:38:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352540.579412 (Exim 4.92) (envelope-from ) id 1o3Bzj-0004pu-Tu; Mon, 20 Jun 2022 07:38:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352540.579412; Mon, 20 Jun 2022 07:38:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzj-0004n7-Js; Mon, 20 Jun 2022 07:38:47 +0000 Received: by outflank-mailman (input) for mailman id 352540; Mon, 20 Jun 2022 07:38:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzg-0002ZD-CV for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:44 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fcb15982-f06b-11ec-b725-ed86ccbb4733; Mon, 20 Jun 2022 09:38:33 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2193721BCE; Mon, 20 Jun 2022 07:38:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E52F6134CA; Mon, 20 Jun 2022 07:38:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OEubNvkjsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:33 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fcb15982-f06b-11ec-b725-ed86ccbb4733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710714; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F2usykdrZz/ETCDtrSzcODBAgM6yVFNOOYprC5PICS8=; b=sSC6tQ1TwuIm9F1IbZobt/BlZYlWRWpysSxHKvHzavFfCHHIa5nFk1ZdZElY8a3WwNwMRA y9ZrzB/r5gPVTVtZ8kKydPNmy8Ic/jBpOArgr7WXEI28MTsM1sqy5oup9ByadnXzGCtIh0 ynmiF7xExpf2uig1Lusce6y7AOxIUqA= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 6/8] mini-os: eliminate console directory Date: Mon, 20 Jun 2022 09:38:18 +0200 Message-Id: <20220620073820.9336-7-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 Merge the two remaining source files in the console directory into a single one and move it to the main directory. Signed-off-by: Juergen Gross --- Makefile | 4 +- console/xencons_ring.c => console.c | 171 ++++++++++++++++++++++++++- console/console.c | 177 ---------------------------- 3 files changed, 170 insertions(+), 182 deletions(-) rename console/xencons_ring.c => console.c (51%) delete mode 100644 console/console.c diff --git a/Makefile b/Makefile index 509d927b..f3acdd2f 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ src-$(CONFIG_CONSFRONT) += consfront.c src-$(CONFIG_TPMFRONT) += tpmfront.c src-$(CONFIG_TPM_TIS) += tpm_tis.c src-$(CONFIG_TPMBACK) += tpmback.c +src-y += console.c src-y += daytime.c src-y += e820.c src-y += events.c @@ -69,9 +70,6 @@ src-y += lib/sys.c src-y += lib/xmalloc.c src-$(CONFIG_LIBXS) += lib/xs.c -src-y += console/console.c -src-y += console/xencons_ring.c - # The common mini-os objects to build. APP_OBJS := OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(src-y)) diff --git a/console/xencons_ring.c b/console.c similarity index 51% rename from console/xencons_ring.c rename to console.c index 495f0a19..29277eac 100644 --- a/console/xencons_ring.c +++ b/console.c @@ -1,3 +1,39 @@ +/* + **************************************************************************** + * (C) 2006 - Grzegorz Milos - Cambridge University + **************************************************************************** + * + * File: console.c + * Author: Grzegorz Milos + * Changes: + * + * Date: Mar 2006 + * + * Environment: Xen Minimal OS + * Description: Console interface. + * + * Handles console I/O. Defines printk. + * + **************************************************************************** + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + #include #include #include @@ -7,12 +43,143 @@ #include #include #include +#include +#include #include #include #include #include -#include -#include + +/* If console not initialised the printk will be sent to xen serial line + NOTE: you need to enable verbose in xen/Rules.mk for it to work. */ +static struct consfront_dev* xen_console = NULL; +static int console_initialised = 0; + +__attribute__((weak)) void console_input(char * buf, unsigned len) +{ + if(len > 0) + { + /* Just repeat what's written */ + buf[len] = '\0'; + printk("%s", buf); + + if(buf[len-1] == '\r') + printk("\nNo console input handler.\n"); + } +} + +#ifndef HAVE_LIBC +void xencons_rx(char *buf, unsigned len, struct pt_regs *regs) +{ + console_input(buf, len); +} + +void xencons_tx(void) +{ + /* Do nothing, handled by _rx */ +} +#endif + + +void console_print(struct consfront_dev *dev, const char *data, int length) +{ + char *curr_char, saved_char; + char copied_str[length+1]; + char *copied_ptr; + int part_len; + int (*ring_send_fn)(struct consfront_dev *dev, const char *data, unsigned length); + + if(!console_initialised) + ring_send_fn = xencons_ring_send_no_notify; + else + ring_send_fn = xencons_ring_send; + + if (dev && dev->is_raw) { + ring_send_fn(dev, data, length); + return; + } + + copied_ptr = copied_str; + memcpy(copied_ptr, data, length); + for(curr_char = copied_ptr; curr_char < copied_ptr+length-1; curr_char++) + { + if(*curr_char == '\n') + { + *curr_char = '\r'; + saved_char = *(curr_char+1); + *(curr_char+1) = '\n'; + part_len = curr_char - copied_ptr + 2; + ring_send_fn(dev, copied_ptr, part_len); + *(curr_char+1) = saved_char; + copied_ptr = curr_char+1; + length -= part_len - 1; + } + } + + if (copied_ptr[length-1] == '\n') { + copied_ptr[length-1] = '\r'; + copied_ptr[length] = '\n'; + length++; + } + + ring_send_fn(dev, copied_ptr, length); +} + +void print(int direct, const char *fmt, va_list args) +{ + static char __print_buf[1024]; + + (void)vsnprintf(__print_buf, sizeof(__print_buf), fmt, args); + + if(direct) + { + (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), __print_buf); + return; + } else { +#ifndef CONFIG_USE_XEN_CONSOLE + if(!console_initialised) +#endif + (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), __print_buf); + + console_print(NULL, __print_buf, strlen(__print_buf)); + } +} + +void printk(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + print(0, fmt, args); + va_end(args); +} + +void xprintk(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + print(1, fmt, args); + va_end(args); +} +void init_console(void) +{ + printk("Initialising console ... "); + xen_console = xencons_ring_init(); + console_initialised = 1; + /* This is also required to notify the daemon */ + printk("done.\n"); +} + +void suspend_console(void) +{ + console_initialised = 0; + xencons_ring_fini(xen_console); +} + +void resume_console(void) +{ + xencons_ring_resume(xen_console); + console_initialised = 1; +} DECLARE_WAIT_QUEUE_HEAD(console_queue); diff --git a/console/console.c b/console/console.c deleted file mode 100644 index 68c8435e..00000000 --- a/console/console.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - **************************************************************************** - * (C) 2006 - Grzegorz Milos - Cambridge University - **************************************************************************** - * - * File: console.h - * Author: Grzegorz Milos - * Changes: - * - * Date: Mar 2006 - * - * Environment: Xen Minimal OS - * Description: Console interface. - * - * Handles console I/O. Defines printk. - * - **************************************************************************** - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -/* If console not initialised the printk will be sent to xen serial line - NOTE: you need to enable verbose in xen/Rules.mk for it to work. */ -static struct consfront_dev* xen_console = NULL; -static int console_initialised = 0; - -__attribute__((weak)) void console_input(char * buf, unsigned len) -{ - if(len > 0) - { - /* Just repeat what's written */ - buf[len] = '\0'; - printk("%s", buf); - - if(buf[len-1] == '\r') - printk("\nNo console input handler.\n"); - } -} - -#ifndef HAVE_LIBC -void xencons_rx(char *buf, unsigned len, struct pt_regs *regs) -{ - console_input(buf, len); -} - -void xencons_tx(void) -{ - /* Do nothing, handled by _rx */ -} -#endif - - -void console_print(struct consfront_dev *dev, const char *data, int length) -{ - char *curr_char, saved_char; - char copied_str[length+1]; - char *copied_ptr; - int part_len; - int (*ring_send_fn)(struct consfront_dev *dev, const char *data, unsigned length); - - if(!console_initialised) - ring_send_fn = xencons_ring_send_no_notify; - else - ring_send_fn = xencons_ring_send; - - if (dev && dev->is_raw) { - ring_send_fn(dev, data, length); - return; - } - - copied_ptr = copied_str; - memcpy(copied_ptr, data, length); - for(curr_char = copied_ptr; curr_char < copied_ptr+length-1; curr_char++) - { - if(*curr_char == '\n') - { - *curr_char = '\r'; - saved_char = *(curr_char+1); - *(curr_char+1) = '\n'; - part_len = curr_char - copied_ptr + 2; - ring_send_fn(dev, copied_ptr, part_len); - *(curr_char+1) = saved_char; - copied_ptr = curr_char+1; - length -= part_len - 1; - } - } - - if (copied_ptr[length-1] == '\n') { - copied_ptr[length-1] = '\r'; - copied_ptr[length] = '\n'; - length++; - } - - ring_send_fn(dev, copied_ptr, length); -} - -void print(int direct, const char *fmt, va_list args) -{ - static char __print_buf[1024]; - - (void)vsnprintf(__print_buf, sizeof(__print_buf), fmt, args); - - if(direct) - { - (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), __print_buf); - return; - } else { -#ifndef CONFIG_USE_XEN_CONSOLE - if(!console_initialised) -#endif - (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), __print_buf); - - console_print(NULL, __print_buf, strlen(__print_buf)); - } -} - -void printk(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - print(0, fmt, args); - va_end(args); -} - -void xprintk(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - print(1, fmt, args); - va_end(args); -} -void init_console(void) -{ - printk("Initialising console ... "); - xen_console = xencons_ring_init(); - console_initialised = 1; - /* This is also required to notify the daemon */ - printk("done.\n"); -} - -void suspend_console(void) -{ - console_initialised = 0; - xencons_ring_fini(xen_console); -} - -void resume_console(void) -{ - xencons_ring_resume(xen_console); - console_initialised = 1; -} From patchwork Mon Jun 20 07:38:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 635CFCCA479 for ; Mon, 20 Jun 2022 07:38:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352534.579373 (Exim 4.92) (envelope-from ) id 1o3Bzf-0003uA-2Z; Mon, 20 Jun 2022 07:38:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352534.579373; Mon, 20 Jun 2022 07:38:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bze-0003sA-Lx; Mon, 20 Jun 2022 07:38:42 +0000 Received: by outflank-mailman (input) for mailman id 352534; Mon, 20 Jun 2022 07:38:40 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzc-0002ZE-KP for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:40 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fd465502-f06b-11ec-bd2d-47488cf2e6aa; Mon, 20 Jun 2022 09:38:34 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5B6ED1F972; Mon, 20 Jun 2022 07:38:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 292A1134CA; Mon, 20 Jun 2022 07:38:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AKiuCPojsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:34 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fd465502-f06b-11ec-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710714; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ij/l8vGwMUP3sj1l6oCVo+3lGirXIhChnHnYSjdN7M4=; b=iF7oXWL274QxV6P/YGQuE7yJf2FZ0UXUVsAp/+MPXoFykVPZWfIApaoD94IxzdB9eHBASW njBlkkiQQWfD4VEiQqxiOKMA4qCWqPyyhvost8/ERAPHX38leEth0ndXibttvUX81T0hpY deQXWgsSL9uNG4oH4OkMlGZriS7IVLY= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 7/8] mini-os: apply coding style to console.c Date: Mon, 20 Jun 2022 09:38:19 +0200 Message-Id: <20220620073820.9336-8-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 Make console.c coding style compliant. Signed-off-by: Juergen Gross --- console.c | 280 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 145 insertions(+), 135 deletions(-) diff --git a/console.c b/console.c index 29277eac..5d205c7d 100644 --- a/console.c +++ b/console.c @@ -1,14 +1,14 @@ -/* +/* **************************************************************************** * (C) 2006 - Grzegorz Milos - Cambridge University **************************************************************************** * * File: console.c * Author: Grzegorz Milos - * Changes: - * + * Changes: + * * Date: Mar 2006 - * + * * Environment: Xen Minimal OS * Description: Console interface. * @@ -21,19 +21,19 @@ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - + #include #include #include @@ -50,26 +50,24 @@ #include #include -/* If console not initialised the printk will be sent to xen serial line - NOTE: you need to enable verbose in xen/Rules.mk for it to work. */ static struct consfront_dev* xen_console = NULL; static int console_initialised = 0; -__attribute__((weak)) void console_input(char * buf, unsigned len) +__attribute__((weak)) void console_input(char *buf, unsigned int len) { - if(len > 0) + if ( len > 0 ) { /* Just repeat what's written */ buf[len] = '\0'; printk("%s", buf); - - if(buf[len-1] == '\r') + + if ( buf[len - 1] == '\r' ) printk("\nNo console input handler.\n"); } } #ifndef HAVE_LIBC -void xencons_rx(char *buf, unsigned len, struct pt_regs *regs) +void xencons_rx(char *buf, unsigned int len, struct pt_regs *regs) { console_input(buf, len); } @@ -80,88 +78,94 @@ void xencons_tx(void) } #endif - void console_print(struct consfront_dev *dev, const char *data, int length) { char *curr_char, saved_char; char copied_str[length+1]; char *copied_ptr; int part_len; - int (*ring_send_fn)(struct consfront_dev *dev, const char *data, unsigned length); + int (*ring_send_fn)(struct consfront_dev *dev, const char *data, + unsigned int length); - if(!console_initialised) + if ( !console_initialised ) ring_send_fn = xencons_ring_send_no_notify; else ring_send_fn = xencons_ring_send; - if (dev && dev->is_raw) { + if ( dev && dev->is_raw ) + { ring_send_fn(dev, data, length); return; } copied_ptr = copied_str; memcpy(copied_ptr, data, length); - for(curr_char = copied_ptr; curr_char < copied_ptr+length-1; curr_char++) + for ( curr_char = copied_ptr; curr_char < copied_ptr + length - 1; + curr_char++ ) { - if(*curr_char == '\n') + if ( *curr_char == '\n' ) { *curr_char = '\r'; - saved_char = *(curr_char+1); - *(curr_char+1) = '\n'; + saved_char = *(curr_char + 1); + *(curr_char + 1) = '\n'; part_len = curr_char - copied_ptr + 2; ring_send_fn(dev, copied_ptr, part_len); - *(curr_char+1) = saved_char; - copied_ptr = curr_char+1; + *(curr_char + 1) = saved_char; + copied_ptr = curr_char + 1; length -= part_len - 1; } } - if (copied_ptr[length-1] == '\n') { - copied_ptr[length-1] = '\r'; + if ( copied_ptr[length - 1] == '\n') + { + copied_ptr[length - 1] = '\r'; copied_ptr[length] = '\n'; length++; } - + ring_send_fn(dev, copied_ptr, length); } void print(int direct, const char *fmt, va_list args) { static char __print_buf[1024]; - + (void)vsnprintf(__print_buf, sizeof(__print_buf), fmt, args); - if(direct) + if ( direct ) { - (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), __print_buf); + (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), + __print_buf); return; - } else { -#ifndef CONFIG_USE_XEN_CONSOLE - if(!console_initialised) -#endif - (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), __print_buf); - - console_print(NULL, __print_buf, strlen(__print_buf)); } +#ifndef CONFIG_USE_XEN_CONSOLE + if ( !console_initialised ) +#endif + (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(__print_buf), + __print_buf); + + console_print(NULL, __print_buf, strlen(__print_buf)); } void printk(const char *fmt, ...) { - va_list args; + va_list args; + va_start(args, fmt); print(0, fmt, args); - va_end(args); + va_end(args); } void xprintk(const char *fmt, ...) { - va_list args; + va_list args; + va_start(args, fmt); print(1, fmt, args); - va_end(args); + va_end(args); } void init_console(void) -{ +{ printk("Initialising console ... "); xen_console = xencons_ring_init(); console_initialised = 1; @@ -186,7 +190,7 @@ DECLARE_WAIT_QUEUE_HEAD(console_queue); static struct xencons_interface *console_ring; uint32_t console_evtchn; -static struct consfront_dev* resume_xen_console(struct consfront_dev* dev); +static struct consfront_dev* resume_xen_console(struct consfront_dev *dev); #ifdef CONFIG_PARAVIRT void get_console(void *p) @@ -201,11 +205,11 @@ void get_console(void *p) { uint64_t v = -1; - if (hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v)) + if ( hvm_get_parameter(HVM_PARAM_CONSOLE_EVTCHN, &v) ) BUG(); console_evtchn = v; - if (hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &v)) + if ( hvm_get_parameter(HVM_PARAM_CONSOLE_PFN, &v) ) BUG(); console_ring = (struct xencons_interface *)map_frame_virt(v); } @@ -214,7 +218,7 @@ void get_console(void *p) static inline void notify_daemon(struct consfront_dev *dev) { /* Use evtchn: this is called early, before irq is set up. */ - if (!dev) + if ( !dev ) notify_remote_via_evtchn(console_evtchn); else notify_remote_via_evtchn(dev->evtchn); @@ -223,36 +227,38 @@ static inline void notify_daemon(struct consfront_dev *dev) static inline struct xencons_interface *xencons_interface(void) { return console_evtchn ? console_ring : NULL; -} - -int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, unsigned len) -{ +} + +int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, + unsigned int len) +{ int sent = 0; - struct xencons_interface *intf; - XENCONS_RING_IDX cons, prod; - - if (!dev) - intf = xencons_interface(); - else - intf = dev->ring; - if (!intf) - return sent; - - cons = intf->out_cons; - prod = intf->out_prod; - mb(); - BUG_ON((prod - cons) > sizeof(intf->out)); - - while ((sent < len) && ((prod - cons) < sizeof(intf->out))) - intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = data[sent++]; - - wmb(); - intf->out_prod = prod; - + struct xencons_interface *intf; + XENCONS_RING_IDX cons, prod; + + if ( !dev ) + intf = xencons_interface(); + else + intf = dev->ring; + if ( !intf ) + return sent; + + cons = intf->out_cons; + prod = intf->out_prod; + mb(); + BUG_ON((prod - cons) > sizeof(intf->out)); + + while ( (sent < len) && ((prod - cons) < sizeof(intf->out)) ) + intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = data[sent++]; + + wmb(); + intf->out_prod = prod; + return sent; } -int xencons_ring_send(struct consfront_dev *dev, const char *data, unsigned len) +int xencons_ring_send(struct consfront_dev *dev, const char *data, + unsigned int len) { int sent; @@ -264,83 +270,85 @@ int xencons_ring_send(struct consfront_dev *dev, const char *data, unsigned len) void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data) { - struct consfront_dev *dev = (struct consfront_dev *) data; + struct consfront_dev *dev = (struct consfront_dev *) data; #ifdef HAVE_LIBC - struct file *file = dev ? get_file_from_fd(dev->fd) : NULL; + struct file *file = dev ? get_file_from_fd(dev->fd) : NULL; - if ( file ) - file->read = true; + if ( file ) + file->read = true; - wake_up(&console_queue); + wake_up(&console_queue); #else - struct xencons_interface *intf = xencons_interface(); - XENCONS_RING_IDX cons, prod; + struct xencons_interface *intf = xencons_interface(); + XENCONS_RING_IDX cons, prod; - cons = intf->in_cons; - prod = intf->in_prod; - mb(); - BUG_ON((prod - cons) > sizeof(intf->in)); + cons = intf->in_cons; + prod = intf->in_prod; + mb(); + BUG_ON((prod - cons) > sizeof(intf->in)); - while (cons != prod) { - xencons_rx(intf->in+MASK_XENCONS_IDX(cons,intf->in), 1, regs); - cons++; - } + while ( cons != prod ) + { + xencons_rx(intf->in + MASK_XENCONS_IDX(cons, intf->in), 1, regs); + cons++; + } - mb(); - intf->in_cons = cons; + mb(); + intf->in_cons = cons; - notify_daemon(dev); + notify_daemon(dev); - xencons_tx(); + xencons_tx(); #endif } #ifdef HAVE_LIBC int xencons_ring_avail(struct consfront_dev *dev) { - struct xencons_interface *intf; - XENCONS_RING_IDX cons, prod; + struct xencons_interface *intf; + XENCONS_RING_IDX cons, prod; - if (!dev) - intf = xencons_interface(); - else - intf = dev->ring; + if ( !dev ) + intf = xencons_interface(); + else + intf = dev->ring; - cons = intf->in_cons; - prod = intf->in_prod; - mb(); - BUG_ON((prod - cons) > sizeof(intf->in)); + cons = intf->in_cons; + prod = intf->in_prod; + mb(); + BUG_ON((prod - cons) > sizeof(intf->in)); - return prod - cons; + return prod - cons; } -int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len) +int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned int len) { - struct xencons_interface *intf; - XENCONS_RING_IDX cons, prod; - unsigned filled = 0; + struct xencons_interface *intf; + XENCONS_RING_IDX cons, prod; + unsigned int filled = 0; - if (!dev) - intf = xencons_interface(); - else - intf = dev->ring; + if ( !dev ) + intf = xencons_interface(); + else + intf = dev->ring; - cons = intf->in_cons; - prod = intf->in_prod; - mb(); - BUG_ON((prod - cons) > sizeof(intf->in)); + cons = intf->in_cons; + prod = intf->in_prod; + mb(); + BUG_ON((prod - cons) > sizeof(intf->in)); - while (filled < len && cons + filled != prod) { - data[filled] = *(intf->in + MASK_XENCONS_IDX(cons + filled, intf->in)); - filled++; - } + while ( filled < len && cons + filled != prod ) + { + data[filled] = *(intf->in + MASK_XENCONS_IDX(cons + filled, intf->in)); + filled++; + } - mb(); - intf->in_cons = cons + filled; + mb(); + intf->in_cons = cons + filled; - notify_daemon(dev); + notify_daemon(dev); - return filled; + return filled; } #endif @@ -348,7 +356,7 @@ struct consfront_dev *xencons_ring_init(void) { struct consfront_dev *dev; - if (!console_evtchn) + if ( !console_evtchn ) return 0; dev = malloc(sizeof(struct consfront_dev)); @@ -365,7 +373,7 @@ struct consfront_dev *xencons_ring_init(void) return resume_xen_console(dev); } -static struct consfront_dev* resume_xen_console(struct consfront_dev* dev) +static struct consfront_dev *resume_xen_console(struct consfront_dev *dev) { int err; @@ -373,7 +381,8 @@ static struct consfront_dev* resume_xen_console(struct consfront_dev* dev) dev->ring = xencons_interface(); err = bind_evtchn(dev->evtchn, console_handle_input, dev); - if (err <= 0) { + if ( err <= 0 ) + { printk("XEN console request chn bind failed %i\n", err); free(dev); return NULL; @@ -386,15 +395,16 @@ static struct consfront_dev* resume_xen_console(struct consfront_dev* dev) return dev; } -void xencons_ring_fini(struct consfront_dev* dev) +void xencons_ring_fini(struct consfront_dev *dev) { - if (dev) + if ( dev ) mask_evtchn(dev->evtchn); } -void xencons_ring_resume(struct consfront_dev* dev) +void xencons_ring_resume(struct consfront_dev *dev) { - if (dev) { + if ( dev ) + { #if CONFIG_PARAVIRT get_console(&start_info); #else From patchwork Mon Jun 20 07:38:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12887070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84A0FC433EF for ; Mon, 20 Jun 2022 07:38:51 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.352530.579336 (Exim 4.92) (envelope-from ) id 1o3Bzb-00035R-MZ; Mon, 20 Jun 2022 07:38:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 352530.579336; Mon, 20 Jun 2022 07:38:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bzb-00032O-H0; Mon, 20 Jun 2022 07:38:39 +0000 Received: by outflank-mailman (input) for mailman id 352530; Mon, 20 Jun 2022 07:38:38 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o3Bza-0002ZE-K0 for xen-devel@lists.xenproject.org; Mon, 20 Jun 2022 07:38:38 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fd8397c4-f06b-11ec-bd2d-47488cf2e6aa; Mon, 20 Jun 2022 09:38:34 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 985DB21BD0; Mon, 20 Jun 2022 07:38:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6206E13A79; Mon, 20 Jun 2022 07:38:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EFuXFvojsGI3DAAAMHmgww (envelope-from ); Mon, 20 Jun 2022 07:38:34 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fd8397c4-f06b-11ec-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1655710714; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g253R54BCUXErJG0A5bqZZ4ZPguYj/1UWM+5iFTL2Q4=; b=NGnw937lMT/LOym5c4FxAJvsiKqbPHFdtXnXWnw+KPZQ2CZdE9erEzVRNC9go0JBFdw03p 8vE7N10ooM3hfysMkQhuqM6HfgEQpdZa1qMynsfHUvdUYEFL6tdgtW5f0TIK0r9ltl89H3 Bz9JR4qLhGl9SYSPaB8KTneMQ/jTnSI= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 8/8] mini-os: add mini-os-debug[.gz] to .gitignore Date: Mon, 20 Jun 2022 09:38:20 +0200 Message-Id: <20220620073820.9336-9-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220620073820.9336-1-jgross@suse.com> References: <20220620073820.9336-1-jgross@suse.com> MIME-Version: 1.0 mini-os-debug and mini-os-debug.gz are created when building Mini-OS, add them to .gitignore. Signed-off-by: Juergen Gross --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d57c2bdd..abef46b2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ include/list.h mini-os mini-os.gz minios-config.mk +mini-os-debug +mini-os-debug.gz