* The lock is not used when the kernel is panicing as it will never recover
* and we want to output no matter what it costs.
*/
-#define CN_LOCK(cons) \
- do { \
- if (panicstr == NULL) \
- mtx_lock_spin(&(cons)->mtx); \
- } while (0)
-#define CN_UNLOCK(cons) \
- do { \
- if (panicstr == NULL) \
- mtx_unlock_spin(&(cons)->mtx); \
- } while (0)
-#define CN_LOCK_ASSERT(cons) mtx_assert(&(cons)->mtx, MA_OWNED)
-#define CN_LOCK_DESTROY(cons) mtx_destroy(&(cons)->mtx)
+static inline void xencons_lock(struct xencons_priv *cons)
+{
+ if (panicstr == NULL)
+ mtx_lock_spin(&cons->mtx);
+
+}
+
+static inline void xencons_unlock(struct xencons_priv *cons)
+{
+ if (panicstr == NULL )
+ mtx_lock_spin(&cons->mtx);
+}
+
+#define xencons_lock_assert(cons) mtx_assert(&(cons)->mtx, MA_OWNED)
/*
* Data for the main console
xencons_read_hypervisor(struct xencons_priv *cons, const char *buffer,
unsigned int size)
{
- CN_LOCK_ASSERT(cons);
+ xencons_lock_assert(cons);
return HYPERVISOR_console_io(CONSOLEIO_read, size, buffer);
}
XENCONS_RING_IDX wcons, wprod;
int sent;
- CN_LOCK_ASSERT(cons);
+ xencons_lock_assert(cons);
/* The console page may have not yet been initialized for HVM domain */
if (__predict_false(!intf))
XENCONS_RING_IDX rcons, rprod;
unsigned int rsz;
- CN_LOCK_ASSERT(cons);
+ xencons_lock_assert(cons);
/* The console page may have not yet been initialized for HVM domain */
if (__predict_false(!intf))
static char buf[16];
int sz;
- CN_LOCK(cons);
+ xencons_lock(cons);
while ((sz = xencons_read(cons, buf, sizeof(buf))) > 0) {
int i;
for (i = 0; i < sz; i++)
cons->rbuf[RBUF_MASK(cons->rp++)] = buf[i];
}
- CN_UNLOCK(cons);
+ xencons_unlock(cons);
}
/* Return true if the write buffer is full */
{
unsigned int used;
- CN_LOCK(cons);
+ xencons_lock(cons);
used = cons->wp - cons->wc;
- CN_UNLOCK(cons);
+ xencons_unlock(cons);
return (used >= WBUF_SIZE);
}
{
int sz;
- CN_LOCK(cons);
+ xencons_lock(cons);
while (cons->wc != cons->wp) {
int sent;
sz = cons->wp - cons->wc;
cons->wc += sent;
}
- CN_UNLOCK(cons);
+ xencons_unlock(cons);
}
static bool
xencons_putc(struct xencons_priv *cons, int c, bool force_flush)
{
- CN_LOCK(cons);
+ xencons_lock(cons);
if ((cons->wp - cons->wc) < WBUF_SIZE)
cons->wbuf[WBUF_MASK(cons->wp++)] = c;
- CN_UNLOCK(cons);
+ xencons_unlock(cons);
xencons_tx_flush(cons, force_flush);
{
int ret;
- CN_LOCK(cons);
+ xencons_lock(cons);
if (cons->rp != cons->rc) {
/* We need to return only one char */
ret = (int)cons->rbuf[RBUF_MASK(cons->rc)];
}
else
ret = -1;
- CN_UNLOCK(cons);
+ xencons_unlock(cons);
return ret;
}