* [PATCH 0/8] mini-os: some cleanup patches
@ 2022-06-20 7:38 Juergen Gross
2022-06-20 7:38 ` [PATCH 1/8] mini-os: drop xenbus directory Juergen Gross
` (9 more replies)
0 siblings, 10 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
Do some cleanups.
No functional change intended, apart from whitespace changes only
minor modifications making code easier to read.
Juergen Gross (8):
mini-os: drop xenbus directory
mini-os: apply coding style to xenbus.c
mini-os: eliminate console/console.h
mini-os: rename console/xenbus.c to consfront.c
mini-os: apply coding style to consfront.c
mini-os: eliminate console directory
mini-os: apply coding style to console.c
mini-os: add mini-os-debug[.gz] to .gitignore
.gitignore | 2 +
Makefile | 9 +-
console/xenbus.c => consfront.c | 99 ++++---
console.c | 415 ++++++++++++++++++++++++++
console/console.c | 177 -----------
console/console.h | 2 -
console/xencons_ring.c | 238 ---------------
include/console.h | 1 +
xenbus/xenbus.c => xenbus.c | 510 +++++++++++++++++++-------------
9 files changed, 778 insertions(+), 675 deletions(-)
rename console/xenbus.c => consfront.c (78%)
create mode 100644 console.c
delete mode 100644 console/console.c
delete mode 100644 console/console.h
delete mode 100644 console/xencons_ring.c
rename xenbus/xenbus.c => xenbus.c (71%)
--
2.35.3
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/8] mini-os: drop xenbus directory
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 7:38 ` [PATCH 2/8] mini-os: apply coding style to xenbus.c Juergen Gross
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
The xenbus directory contains only a single source. Move this source
up and remove the xenbus directory.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
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
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/8] mini-os: apply coding style to xenbus.c
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
2022-06-20 7:38 ` [PATCH 1/8] mini-os: drop xenbus directory Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 7:38 ` [PATCH 3/8] mini-os: eliminate console/console.h Juergen Gross
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
Make xenbus.c coding style compliant.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
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 <mini-os/semaphore.h>
#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 */
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/8] mini-os: eliminate console/console.h
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
2022-06-20 7:38 ` [PATCH 1/8] mini-os: drop xenbus directory Juergen Gross
2022-06-20 7:38 ` [PATCH 2/8] mini-os: apply coding style to xenbus.c Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 7:38 ` [PATCH 4/8] mini-os: rename console/xenbus.c to consfront.c Juergen Gross
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
console/console.h contains only a single prototype. Move that to
include/console.h and remove console/console.h.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
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 <mini-os/events.h>
#include <mini-os/os.h>
#include <mini-os/lib.h>
+#include <mini-os/console.h>
#include <mini-os/xenbus.h>
#include <xen/io/console.h>
#include <xen/io/protocols.h>
#include <xen/io/ring.h>
#include <mini-os/xmalloc.h>
#include <mini-os/gnttab.h>
-#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 <mini-os/events.h>
#include <mini-os/os.h>
#include <mini-os/lib.h>
+#include <mini-os/console.h>
#include <mini-os/xenbus.h>
#include <xen/io/console.h>
#include <xen/io/protocols.h>
@@ -12,7 +13,6 @@
#include <xen/hvm/params.h>
#include <mini-os/xmalloc.h>
#include <mini-os/gnttab.h>
-#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_ */
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/8] mini-os: rename console/xenbus.c to consfront.c
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
` (2 preceding siblings ...)
2022-06-20 7:38 ` [PATCH 3/8] mini-os: eliminate console/console.h Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 7:38 ` [PATCH 5/8] mini-os: apply coding style " Juergen Gross
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
Move console/xenbus.c into the main directory and rename it to
consfront.c.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
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
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/8] mini-os: apply coding style to consfront.c
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
` (3 preceding siblings ...)
2022-06-20 7:38 ` [PATCH 4/8] mini-os: rename console/xenbus.c to consfront.c Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 7:38 ` [PATCH 6/8] mini-os: eliminate console directory Juergen Gross
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
Make consfront.c coding style compliant.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
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
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/8] mini-os: eliminate console directory
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
` (4 preceding siblings ...)
2022-06-20 7:38 ` [PATCH 5/8] mini-os: apply coding style " Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 7:38 ` [PATCH 7/8] mini-os: apply coding style to console.c Juergen Gross
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
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 <jgross@suse.com>
---
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 <mini-os/types.h>
#include <mini-os/wait.h>
#include <mini-os/mm.h>
@@ -7,12 +43,143 @@
#include <mini-os/lib.h>
#include <mini-os/console.h>
#include <mini-os/xenbus.h>
+#include <mini-os/xmalloc.h>
+#include <mini-os/gnttab.h>
#include <xen/io/console.h>
#include <xen/io/protocols.h>
#include <xen/io/ring.h>
#include <xen/hvm/params.h>
-#include <mini-os/xmalloc.h>
-#include <mini-os/gnttab.h>
+
+/* 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 <mini-os/types.h>
-#include <mini-os/wait.h>
-#include <mini-os/mm.h>
-#include <mini-os/hypervisor.h>
-#include <mini-os/events.h>
-#include <mini-os/os.h>
-#include <mini-os/lib.h>
-#include <mini-os/xenbus.h>
-#include <xen/io/console.h>
-
-
-/* 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;
-}
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/8] mini-os: apply coding style to console.c
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
` (5 preceding siblings ...)
2022-06-20 7:38 ` [PATCH 6/8] mini-os: eliminate console directory Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 7:38 ` [PATCH 8/8] mini-os: add mini-os-debug[.gz] to .gitignore Juergen Gross
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
Make console.c coding style compliant.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
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 <mini-os/types.h>
#include <mini-os/wait.h>
#include <mini-os/mm.h>
@@ -50,26 +50,24 @@
#include <xen/io/ring.h>
#include <xen/hvm/params.h>
-/* 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
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 8/8] mini-os: add mini-os-debug[.gz] to .gitignore
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
` (6 preceding siblings ...)
2022-06-20 7:38 ` [PATCH 7/8] mini-os: apply coding style to console.c Juergen Gross
@ 2022-06-20 7:38 ` Juergen Gross
2022-06-20 22:39 ` [PATCH 0/8] mini-os: some cleanup patches Samuel Thibault
2022-07-04 8:37 ` Juergen Gross
9 siblings, 0 replies; 13+ messages in thread
From: Juergen Gross @ 2022-06-20 7:38 UTC (permalink / raw)
To: minios-devel, xen-devel; +Cc: samuel.thibault, wl, Juergen Gross
mini-os-debug and mini-os-debug.gz are created when building Mini-OS,
add them to .gitignore.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
.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
--
2.35.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] mini-os: some cleanup patches
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
` (7 preceding siblings ...)
2022-06-20 7:38 ` [PATCH 8/8] mini-os: add mini-os-debug[.gz] to .gitignore Juergen Gross
@ 2022-06-20 22:39 ` Samuel Thibault
2022-07-04 8:37 ` Juergen Gross
9 siblings, 0 replies; 13+ messages in thread
From: Samuel Thibault @ 2022-06-20 22:39 UTC (permalink / raw)
To: Juergen Gross; +Cc: minios-devel, xen-devel, wl
Hello,
Juergen Gross, le lun. 20 juin 2022 09:38:12 +0200, a ecrit:
> Do some cleanups.
>
> No functional change intended, apart from whitespace changes only
> minor modifications making code easier to read.
>
> Juergen Gross (8):
> mini-os: drop xenbus directory
> mini-os: apply coding style to xenbus.c
> mini-os: eliminate console/console.h
> mini-os: rename console/xenbus.c to consfront.c
> mini-os: apply coding style to consfront.c
> mini-os: eliminate console directory
> mini-os: apply coding style to console.c
> mini-os: add mini-os-debug[.gz] to .gitignore
For the whole series:
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Thanks!
> .gitignore | 2 +
> Makefile | 9 +-
> console/xenbus.c => consfront.c | 99 ++++---
> console.c | 415 ++++++++++++++++++++++++++
> console/console.c | 177 -----------
> console/console.h | 2 -
> console/xencons_ring.c | 238 ---------------
> include/console.h | 1 +
> xenbus/xenbus.c => xenbus.c | 510 +++++++++++++++++++-------------
> 9 files changed, 778 insertions(+), 675 deletions(-)
> rename console/xenbus.c => consfront.c (78%)
> create mode 100644 console.c
> delete mode 100644 console/console.c
> delete mode 100644 console/console.h
> delete mode 100644 console/xencons_ring.c
> rename xenbus/xenbus.c => xenbus.c (71%)
>
> --
> 2.35.3
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] mini-os: some cleanup patches
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
` (8 preceding siblings ...)
2022-06-20 22:39 ` [PATCH 0/8] mini-os: some cleanup patches Samuel Thibault
@ 2022-07-04 8:37 ` Juergen Gross
2022-07-04 8:39 ` Julien Grall
9 siblings, 1 reply; 13+ messages in thread
From: Juergen Gross @ 2022-07-04 8:37 UTC (permalink / raw)
To: minios-devel, xen-devel, committers; +Cc: samuel.thibault, wl
[-- Attachment #1.1.1: Type: text/plain, Size: 1500 bytes --]
On 20.06.22 09:38, Juergen Gross wrote:
> Do some cleanups.
>
> No functional change intended, apart from whitespace changes only
> minor modifications making code easier to read.
>
> Juergen Gross (8):
> mini-os: drop xenbus directory
> mini-os: apply coding style to xenbus.c
> mini-os: eliminate console/console.h
> mini-os: rename console/xenbus.c to consfront.c
> mini-os: apply coding style to consfront.c
> mini-os: eliminate console directory
> mini-os: apply coding style to console.c
> mini-os: add mini-os-debug[.gz] to .gitignore
>
> .gitignore | 2 +
> Makefile | 9 +-
> console/xenbus.c => consfront.c | 99 ++++---
> console.c | 415 ++++++++++++++++++++++++++
> console/console.c | 177 -----------
> console/console.h | 2 -
> console/xencons_ring.c | 238 ---------------
> include/console.h | 1 +
> xenbus/xenbus.c => xenbus.c | 510 +++++++++++++++++++-------------
> 9 files changed, 778 insertions(+), 675 deletions(-)
> rename console/xenbus.c => consfront.c (78%)
> create mode 100644 console.c
> delete mode 100644 console/console.c
> delete mode 100644 console/console.h
> delete mode 100644 console/xencons_ring.c
> rename xenbus/xenbus.c => xenbus.c (71%)
>
Could someone please commit this series? Samuel gave his R-b nearly 2 weeks
ago.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] mini-os: some cleanup patches
2022-07-04 8:37 ` Juergen Gross
@ 2022-07-04 8:39 ` Julien Grall
2022-07-04 8:53 ` Julien Grall
0 siblings, 1 reply; 13+ messages in thread
From: Julien Grall @ 2022-07-04 8:39 UTC (permalink / raw)
To: Juergen Gross, minios-devel, xen-devel, committers; +Cc: samuel.thibault, wl
Hi Juergen,
On 04/07/2022 09:37, Juergen Gross wrote:
> On 20.06.22 09:38, Juergen Gross wrote:
>> Do some cleanups.
>>
>> No functional change intended, apart from whitespace changes only
>> minor modifications making code easier to read.
>>
>> Juergen Gross (8):
>> mini-os: drop xenbus directory
>> mini-os: apply coding style to xenbus.c
>> mini-os: eliminate console/console.h
>> mini-os: rename console/xenbus.c to consfront.c
>> mini-os: apply coding style to consfront.c
>> mini-os: eliminate console directory
>> mini-os: apply coding style to console.c
>> mini-os: add mini-os-debug[.gz] to .gitignore
>>
>> .gitignore | 2 +
>> Makefile | 9 +-
>> console/xenbus.c => consfront.c | 99 ++++---
>> console.c | 415 ++++++++++++++++++++++++++
>> console/console.c | 177 -----------
>> console/console.h | 2 -
>> console/xencons_ring.c | 238 ---------------
>> include/console.h | 1 +
>> xenbus/xenbus.c => xenbus.c | 510 +++++++++++++++++++-------------
>> 9 files changed, 778 insertions(+), 675 deletions(-)
>> rename console/xenbus.c => consfront.c (78%)
>> create mode 100644 console.c
>> delete mode 100644 console/console.c
>> delete mode 100644 console/console.h
>> delete mode 100644 console/xencons_ring.c
>> rename xenbus/xenbus.c => xenbus.c (71%)
>>
>
> Could someone please commit this series? Samuel gave his R-b nearly 2 weeks
> ago.
I will commit this series and the other you pointed out.
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/8] mini-os: some cleanup patches
2022-07-04 8:39 ` Julien Grall
@ 2022-07-04 8:53 ` Julien Grall
0 siblings, 0 replies; 13+ messages in thread
From: Julien Grall @ 2022-07-04 8:53 UTC (permalink / raw)
To: Juergen Gross, minios-devel, xen-devel, committers; +Cc: samuel.thibault, wl
On 04/07/2022 09:39, Julien Grall wrote:
> Hi Juergen,
>
> On 04/07/2022 09:37, Juergen Gross wrote:
>> On 20.06.22 09:38, Juergen Gross wrote:
>>> Do some cleanups.
>>>
>>> No functional change intended, apart from whitespace changes only
>>> minor modifications making code easier to read.
>>>
>>> Juergen Gross (8):
>>> mini-os: drop xenbus directory
>>> mini-os: apply coding style to xenbus.c
>>> mini-os: eliminate console/console.h
>>> mini-os: rename console/xenbus.c to consfront.c
>>> mini-os: apply coding style to consfront.c
>>> mini-os: eliminate console directory
>>> mini-os: apply coding style to console.c
>>> mini-os: add mini-os-debug[.gz] to .gitignore
>>>
>>> .gitignore | 2 +
>>> Makefile | 9 +-
>>> console/xenbus.c => consfront.c | 99 ++++---
>>> console.c | 415 ++++++++++++++++++++++++++
>>> console/console.c | 177 -----------
>>> console/console.h | 2 -
>>> console/xencons_ring.c | 238 ---------------
>>> include/console.h | 1 +
>>> xenbus/xenbus.c => xenbus.c | 510 +++++++++++++++++++-------------
>>> 9 files changed, 778 insertions(+), 675 deletions(-)
>>> rename console/xenbus.c => consfront.c (78%)
>>> create mode 100644 console.c
>>> delete mode 100644 console/console.c
>>> delete mode 100644 console/console.h
>>> delete mode 100644 console/xencons_ring.c
>>> rename xenbus/xenbus.c => xenbus.c (71%)
>>>
>>
>> Could someone please commit this series? Samuel gave his R-b nearly 2
>> weeks
>> ago.
>
> I will commit this series and the other you pointed out.
Done.
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-07-04 8:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-20 7:38 [PATCH 0/8] mini-os: some cleanup patches Juergen Gross
2022-06-20 7:38 ` [PATCH 1/8] mini-os: drop xenbus directory Juergen Gross
2022-06-20 7:38 ` [PATCH 2/8] mini-os: apply coding style to xenbus.c Juergen Gross
2022-06-20 7:38 ` [PATCH 3/8] mini-os: eliminate console/console.h Juergen Gross
2022-06-20 7:38 ` [PATCH 4/8] mini-os: rename console/xenbus.c to consfront.c Juergen Gross
2022-06-20 7:38 ` [PATCH 5/8] mini-os: apply coding style " Juergen Gross
2022-06-20 7:38 ` [PATCH 6/8] mini-os: eliminate console directory Juergen Gross
2022-06-20 7:38 ` [PATCH 7/8] mini-os: apply coding style to console.c Juergen Gross
2022-06-20 7:38 ` [PATCH 8/8] mini-os: add mini-os-debug[.gz] to .gitignore Juergen Gross
2022-06-20 22:39 ` [PATCH 0/8] mini-os: some cleanup patches Samuel Thibault
2022-07-04 8:37 ` Juergen Gross
2022-07-04 8:39 ` Julien Grall
2022-07-04 8:53 ` Julien Grall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.