mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-04 09:50:54 +00:00
HV: Fix missing brackets for MISRA C Violations
Patch 6 of 7. Added changes to make sure Misra C violations are fixed for rules 11S and 12S. Signed-off-by: Arindam Roy <arindam.roy@intel.com>
This commit is contained in:
parent
4aa6cdacf7
commit
af806a93bd
@ -64,8 +64,9 @@ int32_t acrn_insert_request_wait(struct vcpu *vcpu, struct vhm_request *req)
|
|||||||
"vhm_request page broken!");
|
"vhm_request page broken!");
|
||||||
|
|
||||||
|
|
||||||
if (vcpu == NULL || req == NULL || vcpu->vm->sw.io_shared_page == NULL)
|
if (vcpu == NULL || req == NULL || vcpu->vm->sw.io_shared_page == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
req_buf = (union vhm_request_buffer *)(vcpu->vm->sw.io_shared_page);
|
req_buf = (union vhm_request_buffer *)(vcpu->vm->sw.io_shared_page);
|
||||||
|
|
||||||
@ -108,20 +109,22 @@ static void _get_req_info_(struct vhm_request *req, int *id, char *type,
|
|||||||
switch (req->type) {
|
switch (req->type) {
|
||||||
case REQ_PORTIO:
|
case REQ_PORTIO:
|
||||||
(void)strcpy_s(type, 16, "PORTIO");
|
(void)strcpy_s(type, 16, "PORTIO");
|
||||||
if (req->reqs.pio_request.direction == REQUEST_READ)
|
if (req->reqs.pio_request.direction == REQUEST_READ) {
|
||||||
(void)strcpy_s(dir, 16, "READ");
|
(void)strcpy_s(dir, 16, "READ");
|
||||||
else
|
} else {
|
||||||
(void)strcpy_s(dir, 16, "WRITE");
|
(void)strcpy_s(dir, 16, "WRITE");
|
||||||
|
}
|
||||||
*addr = req->reqs.pio_request.address;
|
*addr = req->reqs.pio_request.address;
|
||||||
*val = req->reqs.pio_request.value;
|
*val = req->reqs.pio_request.value;
|
||||||
break;
|
break;
|
||||||
case REQ_MMIO:
|
case REQ_MMIO:
|
||||||
case REQ_WP:
|
case REQ_WP:
|
||||||
(void)strcpy_s(type, 16, "MMIO/WP");
|
(void)strcpy_s(type, 16, "MMIO/WP");
|
||||||
if (req->reqs.mmio_request.direction == REQUEST_READ)
|
if (req->reqs.mmio_request.direction == REQUEST_READ) {
|
||||||
(void)strcpy_s(dir, 16, "READ");
|
(void)strcpy_s(dir, 16, "READ");
|
||||||
else
|
} else {
|
||||||
(void)strcpy_s(dir, 16, "WRITE");
|
(void)strcpy_s(dir, 16, "WRITE");
|
||||||
|
}
|
||||||
*addr = req->reqs.mmio_request.address;
|
*addr = req->reqs.mmio_request.address;
|
||||||
*val = req->reqs.mmio_request.value;
|
*val = req->reqs.mmio_request.value;
|
||||||
break;
|
break;
|
||||||
|
@ -37,9 +37,10 @@ uint16_t allocate_pcpu(void)
|
|||||||
uint16_t i;
|
uint16_t i;
|
||||||
|
|
||||||
for (i = 0U; i < phys_cpu_num; i++) {
|
for (i = 0U; i < phys_cpu_num; i++) {
|
||||||
if (bitmap_test_and_set(i, &pcpu_used_bitmap) == 0)
|
if (bitmap_test_and_set(i, &pcpu_used_bitmap) == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return INVALID_CPU_ID;
|
return INVALID_CPU_ID;
|
||||||
}
|
}
|
||||||
@ -59,9 +60,10 @@ void add_vcpu_to_runqueue(struct vcpu *vcpu)
|
|||||||
int pcpu_id = vcpu->pcpu_id;
|
int pcpu_id = vcpu->pcpu_id;
|
||||||
|
|
||||||
spinlock_obtain(&per_cpu(sched_ctx, pcpu_id).runqueue_lock);
|
spinlock_obtain(&per_cpu(sched_ctx, pcpu_id).runqueue_lock);
|
||||||
if (list_empty(&vcpu->run_list))
|
if (list_empty(&vcpu->run_list)) {
|
||||||
list_add_tail(&vcpu->run_list,
|
list_add_tail(&vcpu->run_list,
|
||||||
&per_cpu(sched_ctx, pcpu_id).runqueue);
|
&per_cpu(sched_ctx, pcpu_id).runqueue);
|
||||||
|
}
|
||||||
spinlock_release(&per_cpu(sched_ctx, pcpu_id).runqueue_lock);
|
spinlock_release(&per_cpu(sched_ctx, pcpu_id).runqueue_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +106,9 @@ int need_reschedule(uint16_t pcpu_id)
|
|||||||
static void context_switch_out(struct vcpu *vcpu)
|
static void context_switch_out(struct vcpu *vcpu)
|
||||||
{
|
{
|
||||||
/* if it's idle thread, no action for switch out */
|
/* if it's idle thread, no action for switch out */
|
||||||
if (vcpu == NULL)
|
if (vcpu == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* cancel event(int, gp, nmi and exception) injection */
|
/* cancel event(int, gp, nmi and exception) injection */
|
||||||
cancel_event_injection(vcpu);
|
cancel_event_injection(vcpu);
|
||||||
@ -124,8 +127,9 @@ static void context_switch_in(struct vcpu *vcpu)
|
|||||||
get_cpu_var(sched_ctx).curr_vcpu = vcpu;
|
get_cpu_var(sched_ctx).curr_vcpu = vcpu;
|
||||||
|
|
||||||
/* if it's idle thread, no action for switch out */
|
/* if it's idle thread, no action for switch out */
|
||||||
if (vcpu == NULL)
|
if (vcpu == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
atomic_store(&vcpu->running, 1);
|
atomic_store(&vcpu->running, 1);
|
||||||
/* FIXME:
|
/* FIXME:
|
||||||
@ -154,14 +158,15 @@ void default_idle(void)
|
|||||||
uint16_t pcpu_id = get_cpu_id();
|
uint16_t pcpu_id = get_cpu_id();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (need_reschedule(pcpu_id) != 0)
|
if (need_reschedule(pcpu_id) != 0) {
|
||||||
schedule();
|
schedule();
|
||||||
else if (need_offline(pcpu_id) != 0)
|
} else if (need_offline(pcpu_id) != 0) {
|
||||||
cpu_dead(pcpu_id);
|
cpu_dead(pcpu_id);
|
||||||
else
|
} else {
|
||||||
__asm __volatile("pause" ::: "memory");
|
__asm __volatile("pause" ::: "memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void switch_to(struct vcpu *curr)
|
static void switch_to(struct vcpu *curr)
|
||||||
{
|
{
|
||||||
|
@ -55,8 +55,9 @@ int64_t hcall_initialize_trusty(struct vcpu *vcpu, uint64_t param)
|
|||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initialize_trusty(vcpu, param))
|
if (!initialize_trusty(vcpu, param)) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,10 @@ static void print_char(char x)
|
|||||||
{
|
{
|
||||||
serial_puts(serial_handle, &x, 1);
|
serial_puts(serial_handle, &x, 1);
|
||||||
|
|
||||||
if (x == '\n')
|
if (x == '\n') {
|
||||||
serial_puts(serial_handle, "\r", 1);
|
serial_puts(serial_handle, "\r", 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int console_init(void)
|
int console_init(void)
|
||||||
{
|
{
|
||||||
@ -154,11 +155,13 @@ void console_dump_bytes(const void *p, unsigned int len)
|
|||||||
|
|
||||||
/* print one row as ASCII characters (if possible) */
|
/* print one row as ASCII characters (if possible) */
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
if ((x[i] < ' ') || (x[i] >= 127))
|
if ((x[i] < ' ') || (x[i] >= 127)) {
|
||||||
console_putc('.');
|
console_putc('.');
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
console_putc(x[i]);
|
console_putc(x[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* continue with next row */
|
/* continue with next row */
|
||||||
console_putc('\n');
|
console_putc('\n');
|
||||||
/* set pointer one row ahead */
|
/* set pointer one row ahead */
|
||||||
@ -217,6 +220,7 @@ void console_setup_timer(void)
|
|||||||
fire_tsc, TICK_MODE_PERIODIC, period_in_cycle);
|
fire_tsc, TICK_MODE_PERIODIC, period_in_cycle);
|
||||||
|
|
||||||
/* Start an periodic timer */
|
/* Start an periodic timer */
|
||||||
if (add_timer(&console_timer) != 0)
|
if (add_timer(&console_timer) != 0) {
|
||||||
pr_err("Failed to add console kick timer");
|
pr_err("Failed to add console kick timer");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -27,14 +27,16 @@ static inline void alloc_earlylog_sbuf(uint16_t pcpu_id)
|
|||||||
- SBUF_HEAD_SIZE) / ele_size;
|
- SBUF_HEAD_SIZE) / ele_size;
|
||||||
|
|
||||||
per_cpu(earlylog_sbuf, pcpu_id) = sbuf_allocate(ele_num, ele_size);
|
per_cpu(earlylog_sbuf, pcpu_id) = sbuf_allocate(ele_num, ele_size);
|
||||||
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL)
|
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL) {
|
||||||
printf("failed to allcate sbuf for hvlog - %hu\n", pcpu_id);
|
printf("failed to allcate sbuf for hvlog - %hu\n", pcpu_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void free_earlylog_sbuf(uint16_t pcpu_id)
|
static inline void free_earlylog_sbuf(uint16_t pcpu_id)
|
||||||
{
|
{
|
||||||
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL)
|
if (per_cpu(earlylog_sbuf, pcpu_id) == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
free(per_cpu(earlylog_sbuf, pcpu_id));
|
free(per_cpu(earlylog_sbuf, pcpu_id));
|
||||||
per_cpu(earlylog_sbuf, pcpu_id) = NULL;
|
per_cpu(earlylog_sbuf, pcpu_id) = NULL;
|
||||||
@ -61,9 +63,10 @@ static int do_copy_earlylog(struct shared_buf *dst_sbuf,
|
|||||||
|
|
||||||
(void)memcpy_s((void *)dst_sbuf, buf_size,
|
(void)memcpy_s((void *)dst_sbuf, buf_size,
|
||||||
(void *)src_sbuf, valid_size);
|
(void *)src_sbuf, valid_size);
|
||||||
if (dst_sbuf->tail != cur_tail)
|
if (dst_sbuf->tail != cur_tail) {
|
||||||
/* there is chance to lose new log from certain pcpu */
|
/* there is chance to lose new log from certain pcpu */
|
||||||
dst_sbuf->tail = cur_tail;
|
dst_sbuf->tail = cur_tail;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -96,8 +99,9 @@ void do_logmsg(uint32_t severity, const char *fmt, ...)
|
|||||||
do_mem_log = ((logmsg.flags & LOG_FLAG_MEMORY) != 0U &&
|
do_mem_log = ((logmsg.flags & LOG_FLAG_MEMORY) != 0U &&
|
||||||
(severity <= mem_loglevel));
|
(severity <= mem_loglevel));
|
||||||
|
|
||||||
if (!do_console_log && !do_mem_log)
|
if (!do_console_log && !do_mem_log) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get time-stamp value */
|
/* Get time-stamp value */
|
||||||
timestamp = rdtsc();
|
timestamp = rdtsc();
|
||||||
@ -170,34 +174,39 @@ void print_logmsg_buffer(uint16_t pcpu_id)
|
|||||||
struct shared_buf **sbuf;
|
struct shared_buf **sbuf;
|
||||||
int is_earlylog = 0;
|
int is_earlylog = 0;
|
||||||
|
|
||||||
if (pcpu_id >= phys_cpu_num)
|
if (pcpu_id >= phys_cpu_num) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (per_cpu(earlylog_sbuf, pcpu_id) != NULL) {
|
if (per_cpu(earlylog_sbuf, pcpu_id) != NULL) {
|
||||||
sbuf = &per_cpu(earlylog_sbuf, pcpu_id);
|
sbuf = &per_cpu(earlylog_sbuf, pcpu_id);
|
||||||
is_earlylog = 1;
|
is_earlylog = 1;
|
||||||
} else
|
} else {
|
||||||
sbuf = (struct shared_buf **)
|
sbuf = (struct shared_buf **)
|
||||||
&per_cpu(sbuf, pcpu_id)[ACRN_HVLOG];
|
&per_cpu(sbuf, pcpu_id)[ACRN_HVLOG];
|
||||||
|
}
|
||||||
|
|
||||||
spinlock_irqsave_obtain(&(logmsg.lock));
|
spinlock_irqsave_obtain(&(logmsg.lock));
|
||||||
if ((*sbuf) != NULL)
|
if ((*sbuf) != NULL) {
|
||||||
printf("CPU%hu: head: 0x%x, tail: 0x%x %s\n\r",
|
printf("CPU%hu: head: 0x%x, tail: 0x%x %s\n\r",
|
||||||
pcpu_id, (*sbuf)->head, (*sbuf)->tail,
|
pcpu_id, (*sbuf)->head, (*sbuf)->tail,
|
||||||
(is_earlylog != 0) ? "[earlylog]" : "");
|
(is_earlylog != 0) ? "[earlylog]" : "");
|
||||||
|
}
|
||||||
spinlock_irqrestore_release(&(logmsg.lock));
|
spinlock_irqrestore_release(&(logmsg.lock));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
(void)memset(buffer, 0, LOG_ENTRY_SIZE + 1);
|
(void)memset(buffer, 0, LOG_ENTRY_SIZE + 1);
|
||||||
|
|
||||||
if (*sbuf == NULL)
|
if (*sbuf == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
read_cnt = sbuf_get(*sbuf, (uint8_t *)buffer);
|
read_cnt = sbuf_get(*sbuf, (uint8_t *)buffer);
|
||||||
|
|
||||||
if (read_cnt <= 0)
|
if (read_cnt <= 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
idx = (read_cnt < LOG_ENTRY_SIZE) ? read_cnt : LOG_ENTRY_SIZE;
|
idx = (read_cnt < LOG_ENTRY_SIZE) ? read_cnt : LOG_ENTRY_SIZE;
|
||||||
buffer[idx] = '\0';
|
buffer[idx] = '\0';
|
||||||
|
@ -16,18 +16,16 @@ static int charout(int cmd, const char *s, int sz, void *hnd)
|
|||||||
/* copy mode ? */
|
/* copy mode ? */
|
||||||
if (cmd == PRINT_CMD_COPY) {
|
if (cmd == PRINT_CMD_COPY) {
|
||||||
/* copy all characters until NUL is found */
|
/* copy all characters until NUL is found */
|
||||||
if (sz < 0)
|
if (sz < 0) {
|
||||||
s += console_puts(s);
|
s += console_puts(s);
|
||||||
|
} else { /* copy 'sz' characters */
|
||||||
/* copy 'sz' characters */
|
|
||||||
else
|
|
||||||
s += console_write(s, sz);
|
s += console_write(s, sz);
|
||||||
|
}
|
||||||
|
|
||||||
*nchars += (s - p);
|
*nchars += (s - p);
|
||||||
return *nchars;
|
return *nchars;
|
||||||
}
|
} else {
|
||||||
/* fill mode */
|
/* fill mode */
|
||||||
else {
|
|
||||||
*nchars += sz;
|
*nchars += sz;
|
||||||
while (sz != 0) {
|
while (sz != 0) {
|
||||||
console_putc(*s);
|
console_putc(*s);
|
||||||
|
@ -51,8 +51,9 @@ struct shared_buf *sbuf_allocate(uint32_t ele_num, uint32_t ele_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sbuf_allocate_size = sbuf_calculate_allocate_size(ele_num, ele_size);
|
sbuf_allocate_size = sbuf_calculate_allocate_size(ele_num, ele_size);
|
||||||
if (sbuf_allocate_size == 0U)
|
if (sbuf_allocate_size == 0U) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
sbuf = calloc(1, sbuf_allocate_size);
|
sbuf = calloc(1, sbuf_allocate_size);
|
||||||
if (sbuf == NULL) {
|
if (sbuf == NULL) {
|
||||||
@ -84,8 +85,9 @@ int sbuf_get(struct shared_buf *sbuf, uint8_t *data)
|
|||||||
{
|
{
|
||||||
const void *from;
|
const void *from;
|
||||||
|
|
||||||
if ((sbuf == NULL) || (data == NULL))
|
if ((sbuf == NULL) || (data == NULL)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (sbuf_is_empty(sbuf)) {
|
if (sbuf_is_empty(sbuf)) {
|
||||||
/* no data available */
|
/* no data available */
|
||||||
@ -125,8 +127,9 @@ int sbuf_put(struct shared_buf *sbuf, uint8_t *data)
|
|||||||
uint32_t next_tail;
|
uint32_t next_tail;
|
||||||
bool trigger_overwrite = false;
|
bool trigger_overwrite = false;
|
||||||
|
|
||||||
if ((sbuf == NULL) || (data == NULL))
|
if ((sbuf == NULL) || (data == NULL)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
next_tail = sbuf_next_ptr(sbuf->tail, sbuf->ele_size, sbuf->size);
|
next_tail = sbuf_next_ptr(sbuf->tail, sbuf->ele_size, sbuf->size);
|
||||||
/* if this write would trigger overrun */
|
/* if this write would trigger overrun */
|
||||||
@ -156,8 +159,9 @@ int sbuf_put(struct shared_buf *sbuf, uint8_t *data)
|
|||||||
int sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva)
|
int sbuf_share_setup(uint16_t pcpu_id, uint32_t sbuf_id, uint64_t *hva)
|
||||||
{
|
{
|
||||||
if (pcpu_id >= phys_cpu_num ||
|
if (pcpu_id >= phys_cpu_num ||
|
||||||
sbuf_id >= ACRN_SBUF_ID_MAX)
|
sbuf_id >= ACRN_SBUF_ID_MAX) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
per_cpu(sbuf, pcpu_id)[sbuf_id] = hva;
|
per_cpu(sbuf, pcpu_id)[sbuf_id] = hva;
|
||||||
pr_info("%s share sbuf for pCPU[%u] with sbuf_id[%u] setup successfully",
|
pr_info("%s share sbuf for pCPU[%u] with sbuf_id[%u] setup successfully",
|
||||||
|
@ -18,13 +18,15 @@ static struct uart *get_uart_by_id(const char *uart_id, uint32_t *index)
|
|||||||
while (sio_ports[*index] != NULL) {
|
while (sio_ports[*index] != NULL) {
|
||||||
if (strncmp(sio_ports[*index]->tgt_uart->uart_id, uart_id,
|
if (strncmp(sio_ports[*index]->tgt_uart->uart_id, uart_id,
|
||||||
strnlen_s(sio_ports[*index]->tgt_uart->uart_id,
|
strnlen_s(sio_ports[*index]->tgt_uart->uart_id,
|
||||||
SERIAL_ID_MAX_LENGTH)) == 0)
|
SERIAL_ID_MAX_LENGTH)) == 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* No device is found if index reaches end of array. */
|
/* No device is found if index reaches end of array. */
|
||||||
(*index)++;
|
(*index)++;
|
||||||
if (*index == SERIAL_MAX_DEVS)
|
if (*index == SERIAL_MAX_DEVS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return sio_ports[*index];
|
return sio_ports[*index];
|
||||||
@ -66,8 +68,9 @@ int serial_init(void)
|
|||||||
status = sio_ports[index]->tgt_uart->
|
status = sio_ports[index]->tgt_uart->
|
||||||
init(sio_ports[index]->tgt_uart);
|
init(sio_ports[index]->tgt_uart);
|
||||||
|
|
||||||
if (status == 0)
|
if (status == 0) {
|
||||||
sio_initialized[index] = true;
|
sio_initialized[index] = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
status = -ENOMEM;
|
status = -ENOMEM;
|
||||||
break;
|
break;
|
||||||
@ -105,9 +108,10 @@ uint32_t serial_open(const char *uart_id)
|
|||||||
/* Open the UART hardware with default configuration. */
|
/* Open the UART hardware with default configuration. */
|
||||||
status = uart->tgt_uart->open(uart->tgt_uart, &(uart->config));
|
status = uart->tgt_uart->open(uart->tgt_uart, &(uart->config));
|
||||||
|
|
||||||
if (status == 0)
|
if (status == 0) {
|
||||||
uart->open_flag = true;
|
uart->open_flag = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Already open serial device */
|
/* Already open serial device */
|
||||||
else if (uart != NULL && uart->open_flag == true) {
|
else if (uart != NULL && uart->open_flag == true) {
|
||||||
@ -135,12 +139,14 @@ uint32_t serial_get_rx_data(uint32_t uart_handle)
|
|||||||
return 0U;
|
return 0U;
|
||||||
|
|
||||||
index = SERIAL_DECODE_INDEX(uart_handle);
|
index = SERIAL_DECODE_INDEX(uart_handle);
|
||||||
if (index >= SERIAL_MAX_DEVS)
|
if (index >= SERIAL_MAX_DEVS) {
|
||||||
return 0U;
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
uart = sio_ports[index];
|
uart = sio_ports[index];
|
||||||
if (uart == NULL)
|
if (uart == NULL) {
|
||||||
return 0U;
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
/* Place all the data available in RX FIFO, in circular buffer */
|
/* Place all the data available in RX FIFO, in circular buffer */
|
||||||
data_avail = uart->tgt_uart->rx_data_is_avail(
|
data_avail = uart->tgt_uart->rx_data_is_avail(
|
||||||
@ -192,18 +198,21 @@ int serial_getc(uint32_t uart_handle)
|
|||||||
uint32_t index;
|
uint32_t index;
|
||||||
int status = SERIAL_DEV_NOT_FOUND;
|
int status = SERIAL_DEV_NOT_FOUND;
|
||||||
|
|
||||||
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
|
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
index = SERIAL_DECODE_INDEX(uart_handle);
|
index = SERIAL_DECODE_INDEX(uart_handle);
|
||||||
|
|
||||||
if (index >= SERIAL_MAX_DEVS)
|
if (index >= SERIAL_MAX_DEVS) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
port = sio_ports[index];
|
port = sio_ports[index];
|
||||||
|
|
||||||
if (port == NULL)
|
if (port == NULL) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
/* First read a character from the circular buffer regardless of the
|
/* First read a character from the circular buffer regardless of the
|
||||||
* read mode of UART port. If status is not CBUFFER_EMPTY, character
|
* read mode of UART port. If status is not CBUFFER_EMPTY, character
|
||||||
@ -235,15 +244,18 @@ int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length)
|
|||||||
uint32_t index;
|
uint32_t index;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if ((buffer == NULL) || (length == 0U))
|
if ((buffer == NULL) || (length == 0U)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
|
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
index = SERIAL_DECODE_INDEX(uart_handle);
|
index = SERIAL_DECODE_INDEX(uart_handle);
|
||||||
if (index >= SERIAL_MAX_DEVS)
|
if (index >= SERIAL_MAX_DEVS) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
port = sio_ports[index];
|
port = sio_ports[index];
|
||||||
if ((port != NULL) && (port->open_flag == true)) {
|
if ((port != NULL) && (port->open_flag == true)) {
|
||||||
@ -256,8 +268,9 @@ int serial_gets(uint32_t uart_handle, char *buffer, uint32_t length)
|
|||||||
/* Restore interrupts to original level. */
|
/* Restore interrupts to original level. */
|
||||||
spinlock_release(&port->buffer_lock);
|
spinlock_release(&port->buffer_lock);
|
||||||
|
|
||||||
if (status <= 0)
|
if (status <= 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Save character in buffer */
|
/* Save character in buffer */
|
||||||
*data_read = (char) c;
|
*data_read = (char) c;
|
||||||
@ -274,18 +287,21 @@ static int serial_putc(uint32_t uart_handle, int c)
|
|||||||
struct uart *uart;
|
struct uart *uart;
|
||||||
int busy;
|
int busy;
|
||||||
|
|
||||||
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
|
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
|
||||||
return SERIAL_EOF;
|
return SERIAL_EOF;
|
||||||
|
}
|
||||||
|
|
||||||
index = SERIAL_DECODE_INDEX(uart_handle);
|
index = SERIAL_DECODE_INDEX(uart_handle);
|
||||||
|
|
||||||
if (index >= SERIAL_MAX_DEVS)
|
if (index >= SERIAL_MAX_DEVS) {
|
||||||
return SERIAL_EOF;
|
return SERIAL_EOF;
|
||||||
|
}
|
||||||
|
|
||||||
uart = sio_ports[index];
|
uart = sio_ports[index];
|
||||||
|
|
||||||
if (uart == NULL)
|
if (uart == NULL) {
|
||||||
return SERIAL_EOF;
|
return SERIAL_EOF;
|
||||||
|
}
|
||||||
|
|
||||||
/* Wait for TX hardware to be ready */
|
/* Wait for TX hardware to be ready */
|
||||||
do {
|
do {
|
||||||
@ -306,21 +322,25 @@ int serial_puts(uint32_t uart_handle, const char *s, uint32_t length)
|
|||||||
struct uart *port;
|
struct uart *port;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
if ((s == NULL) || (length == 0U))
|
if ((s == NULL) || (length == 0U)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!SERIAL_VALIDATE_HANDLE(uart_handle))
|
if (!SERIAL_VALIDATE_HANDLE(uart_handle)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
index = SERIAL_DECODE_INDEX(uart_handle);
|
index = SERIAL_DECODE_INDEX(uart_handle);
|
||||||
|
|
||||||
if (index >= SERIAL_MAX_DEVS)
|
if (index >= SERIAL_MAX_DEVS) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
port = sio_ports[index];
|
port = sio_ports[index];
|
||||||
|
|
||||||
if (port == NULL)
|
if (port == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab the semaphore so that strings between threads do not
|
* Grab the semaphore so that strings between threads do not
|
||||||
|
@ -240,14 +240,16 @@ struct shell_cmd *shell_find_cmd(struct shell *p_shell, const char *cmd_str)
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
struct shell_cmd *p_cmd = NULL;
|
struct shell_cmd *p_cmd = NULL;
|
||||||
|
|
||||||
if (p_shell->cmd_count <= 0U)
|
if (p_shell->cmd_count <= 0U) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0U; i < p_shell->cmd_count; i++) {
|
for (i = 0U; i < p_shell->cmd_count; i++) {
|
||||||
p_cmd = &p_shell->shell_cmd[i];
|
p_cmd = &p_shell->shell_cmd[i];
|
||||||
if (strcmp(p_cmd->str, cmd_str) == 0)
|
if (strcmp(p_cmd->str, cmd_str) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (i == p_shell->cmd_count) {
|
if (i == p_shell->cmd_count) {
|
||||||
/* No commands in the list. */
|
/* No commands in the list. */
|
||||||
@ -274,9 +276,10 @@ void kick_shell(struct shell *p_shell)
|
|||||||
if (vuart_console_active() == NULL) {
|
if (vuart_console_active() == NULL) {
|
||||||
/* Prompt the user for a selection. */
|
/* Prompt the user for a selection. */
|
||||||
if ((is_cmd_cmplt != 0U) &&
|
if ((is_cmd_cmplt != 0U) &&
|
||||||
(p_shell->session_io.io_puts != NULL))
|
(p_shell->session_io.io_puts != NULL)) {
|
||||||
p_shell->session_io.io_puts(p_shell,
|
p_shell->session_io.io_puts(p_shell,
|
||||||
SHELL_PROMPT_STR);
|
SHELL_PROMPT_STR);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get user's input */
|
/* Get user's input */
|
||||||
is_cmd_cmplt = shell_input_line(p_shell);
|
is_cmd_cmplt = shell_input_line(p_shell);
|
||||||
@ -284,10 +287,11 @@ void kick_shell(struct shell *p_shell)
|
|||||||
/* If user has pressed the ENTER then process
|
/* If user has pressed the ENTER then process
|
||||||
* the command
|
* the command
|
||||||
*/
|
*/
|
||||||
if (is_cmd_cmplt != 0U)
|
if (is_cmd_cmplt != 0U) {
|
||||||
/* Process current input line. */
|
/* Process current input line. */
|
||||||
status = shell_process(p_shell);
|
status = shell_process(p_shell);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Serial port handle couldn't be obtained. Stop the shell
|
/* Serial port handle couldn't be obtained. Stop the shell
|
||||||
* task.
|
* task.
|
||||||
@ -795,8 +799,9 @@ int shell_vcpu_dumpmem(struct shell *p_shell,
|
|||||||
|
|
||||||
gva = strtoul_hex(argv[3]);
|
gva = strtoul_hex(argv[3]);
|
||||||
|
|
||||||
if (argc == 5)
|
if (argc == 5) {
|
||||||
length = atoi(argv[4]);
|
length = atoi(argv[4]);
|
||||||
|
}
|
||||||
|
|
||||||
if (length > MAX_MEMDUMP_LEN) {
|
if (length > MAX_MEMDUMP_LEN) {
|
||||||
shell_puts(p_shell, "over max length, round back\r\n");
|
shell_puts(p_shell, "over max length, round back\r\n");
|
||||||
@ -884,8 +889,9 @@ int shell_show_cpu_int(struct shell *p_shell,
|
|||||||
{
|
{
|
||||||
char *temp_str = alloc_page();
|
char *temp_str = alloc_page();
|
||||||
|
|
||||||
if (temp_str == NULL)
|
if (temp_str == NULL) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
get_cpu_interrupt_info(temp_str, CPU_PAGE_SIZE);
|
get_cpu_interrupt_info(temp_str, CPU_PAGE_SIZE);
|
||||||
shell_puts(p_shell, temp_str);
|
shell_puts(p_shell, temp_str);
|
||||||
@ -900,8 +906,9 @@ int shell_show_ptdev_info(struct shell *p_shell,
|
|||||||
{
|
{
|
||||||
char *temp_str = alloc_page();
|
char *temp_str = alloc_page();
|
||||||
|
|
||||||
if (temp_str == NULL)
|
if (temp_str == NULL) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
get_ptdev_info(temp_str, CPU_PAGE_SIZE);
|
get_ptdev_info(temp_str, CPU_PAGE_SIZE);
|
||||||
shell_puts(p_shell, temp_str);
|
shell_puts(p_shell, temp_str);
|
||||||
@ -922,8 +929,9 @@ int shell_show_req_info(struct shell *p_shell,
|
|||||||
{
|
{
|
||||||
char *temp_str = alloc_page();
|
char *temp_str = alloc_page();
|
||||||
|
|
||||||
if (temp_str == NULL)
|
if (temp_str == NULL) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
get_req_info(temp_str, CPU_PAGE_SIZE);
|
get_req_info(temp_str, CPU_PAGE_SIZE);
|
||||||
shell_puts(p_shell, temp_str);
|
shell_puts(p_shell, temp_str);
|
||||||
@ -938,15 +946,17 @@ int shell_show_vioapic_info(struct shell *p_shell, int argc, char **argv)
|
|||||||
char *temp_str = alloc_page();
|
char *temp_str = alloc_page();
|
||||||
uint32_t vmid;
|
uint32_t vmid;
|
||||||
|
|
||||||
if (temp_str == NULL)
|
if (temp_str == NULL) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
/* User input invalidation */
|
/* User input invalidation */
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
snprintf(temp_str, CPU_PAGE_SIZE, "\r\nvmid param needed\r\n");
|
snprintf(temp_str, CPU_PAGE_SIZE, "\r\nvmid param needed\r\n");
|
||||||
goto END;
|
goto END;
|
||||||
} else
|
} else {
|
||||||
vmid = atoi(argv[1]);
|
vmid = atoi(argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
get_vioapic_info(temp_str, CPU_PAGE_SIZE, vmid);
|
get_vioapic_info(temp_str, CPU_PAGE_SIZE, vmid);
|
||||||
END:
|
END:
|
||||||
@ -961,8 +971,9 @@ int shell_show_ioapic_info(struct shell *p_shell,
|
|||||||
{
|
{
|
||||||
char *temp_str = alloc_pages(2);
|
char *temp_str = alloc_pages(2);
|
||||||
|
|
||||||
if (temp_str == NULL)
|
if (temp_str == NULL) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
get_ioapic_info(temp_str, 2 * CPU_PAGE_SIZE);
|
get_ioapic_info(temp_str, 2 * CPU_PAGE_SIZE);
|
||||||
shell_puts(p_shell, temp_str);
|
shell_puts(p_shell, temp_str);
|
||||||
@ -977,8 +988,9 @@ int shell_show_vmexit_profile(struct shell *p_shell,
|
|||||||
{
|
{
|
||||||
char *temp_str = alloc_pages(2);
|
char *temp_str = alloc_pages(2);
|
||||||
|
|
||||||
if (temp_str == NULL)
|
if (temp_str == NULL) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
get_vmexit_profile(temp_str, 2*CPU_PAGE_SIZE);
|
get_vmexit_profile(temp_str, 2*CPU_PAGE_SIZE);
|
||||||
shell_puts(p_shell, temp_str);
|
shell_puts(p_shell, temp_str);
|
||||||
@ -997,8 +1009,9 @@ int shell_dump_logbuf(__unused struct shell *p_shell,
|
|||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
val = atoi(argv[1]);
|
val = atoi(argv[1]);
|
||||||
if (val < 0)
|
if (val < 0) {
|
||||||
return status;
|
return status;
|
||||||
|
}
|
||||||
pcpu_id = (uint16_t)val;
|
pcpu_id = (uint16_t)val;
|
||||||
print_logmsg_buffer(pcpu_id);
|
print_logmsg_buffer(pcpu_id);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -138,8 +138,9 @@ int shell_init(void)
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = shell_construct(&serial_session);
|
status = shell_construct(&serial_session);
|
||||||
if (status != 0)
|
if (status != 0) {
|
||||||
return status;
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the function pointers for the shell i/p and o/p functions */
|
/* Set the function pointers for the shell i/p and o/p functions */
|
||||||
serial_session->session_io.io_init = shell_init_serial;
|
serial_session->session_io.io_init = shell_init_serial;
|
||||||
@ -201,8 +202,9 @@ int shell_switch_console(void)
|
|||||||
struct vuart *vuart;
|
struct vuart *vuart;
|
||||||
|
|
||||||
vuart = vuart_console_active();
|
vuart = vuart_console_active();
|
||||||
if (vuart == NULL)
|
if (vuart == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
vuart->active = false;
|
vuart->active = false;
|
||||||
/* Output that switching to ACRN shell */
|
/* Output that switching to ACRN shell */
|
||||||
|
@ -89,8 +89,9 @@ static int uart16550_calc_baud_div(__unused struct tgt_uart *tgt_uart,
|
|||||||
{
|
{
|
||||||
uint32_t baud_multiplier = baud_rate < BAUD_460800 ? 16 : 13;
|
uint32_t baud_multiplier = baud_rate < BAUD_460800 ? 16 : 13;
|
||||||
|
|
||||||
if (baud_rate == 0)
|
if (baud_rate == 0) {
|
||||||
baud_rate = BAUD_115200;
|
baud_rate = BAUD_115200;
|
||||||
|
}
|
||||||
*baud_div_ptr = ref_freq / (baud_multiplier * baud_rate);
|
*baud_div_ptr = ref_freq / (baud_multiplier * baud_rate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -154,8 +155,9 @@ static int uart16550_open(struct tgt_uart *tgt_uart,
|
|||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
if (strcmp(tgt_uart->uart_id, "STDIO") == 0) {
|
if (strcmp(tgt_uart->uart_id, "STDIO") == 0) {
|
||||||
if (atomic_cmpxchg(&tgt_uart->open_count, 0, 1) != 0)
|
if (atomic_cmpxchg(&tgt_uart->open_count, 0, 1) != 0) {
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
/* Call UART setup function */
|
/* Call UART setup function */
|
||||||
/* Enable TX and RX FIFOs */
|
/* Enable TX and RX FIFOs */
|
||||||
@ -221,16 +223,19 @@ static uint32_t uart16550_get_rx_err(uint32_t rx_data)
|
|||||||
uint32_t rx_status = SD_RX_NO_ERROR;
|
uint32_t rx_status = SD_RX_NO_ERROR;
|
||||||
|
|
||||||
/* Check for RX overrun error */
|
/* Check for RX overrun error */
|
||||||
if ((rx_data & LSR_OE) != 0U)
|
if ((rx_data & LSR_OE) != 0U) {
|
||||||
rx_status |= SD_RX_OVERRUN_ERROR;
|
rx_status |= SD_RX_OVERRUN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for RX parity error */
|
/* Check for RX parity error */
|
||||||
if ((rx_data & LSR_PE) != 0U)
|
if ((rx_data & LSR_PE) != 0U) {
|
||||||
rx_status |= SD_RX_PARITY_ERROR;
|
rx_status |= SD_RX_PARITY_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for RX frame error */
|
/* Check for RX frame error */
|
||||||
if ((rx_data & LSR_FE) != 0U)
|
if ((rx_data & LSR_FE) != 0U) {
|
||||||
rx_status |= SD_RX_FRAME_ERROR;
|
rx_status |= SD_RX_FRAME_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return the rx status */
|
/* Return the rx status */
|
||||||
return rx_status;
|
return rx_status;
|
||||||
@ -274,9 +279,10 @@ static void uart16550_write(struct tgt_uart *tgt_uart,
|
|||||||
uart16550_write_reg(tgt_uart->base_address,
|
uart16550_write_reg(tgt_uart->base_address,
|
||||||
*(uint8_t *)buffer, THR_IDX);
|
*(uint8_t *)buffer, THR_IDX);
|
||||||
|
|
||||||
if (bytes_written != NULL)
|
if (bytes_written != NULL) {
|
||||||
*bytes_written = 1;
|
*bytes_written = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool uart16550_tx_is_busy(struct tgt_uart *tgt_uart)
|
static bool uart16550_tx_is_busy(struct tgt_uart *tgt_uart)
|
||||||
{
|
{
|
||||||
|
@ -82,9 +82,10 @@ static char fifo_getchar(struct fifo *fifo)
|
|||||||
fifo->rindex = (fifo->rindex + 1) % fifo->size;
|
fifo->rindex = (fifo->rindex + 1) % fifo->size;
|
||||||
fifo->num--;
|
fifo->num--;
|
||||||
return c;
|
return c;
|
||||||
} else
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int fifo_numchars(struct fifo *fifo)
|
static int fifo_numchars(struct fifo *fifo)
|
||||||
{
|
{
|
||||||
@ -100,15 +101,16 @@ static int fifo_numchars(struct fifo *fifo)
|
|||||||
*/
|
*/
|
||||||
static uint8_t uart_intr_reason(struct vuart *vu)
|
static uint8_t uart_intr_reason(struct vuart *vu)
|
||||||
{
|
{
|
||||||
if ((vu->lsr & LSR_OE) != 0 && (vu->ier & IER_ELSI) != 0)
|
if ((vu->lsr & LSR_OE) != 0 && (vu->ier & IER_ELSI) != 0) {
|
||||||
return IIR_RLS;
|
return IIR_RLS;
|
||||||
else if (fifo_numchars(&vu->rxfifo) > 0 && (vu->ier & IER_ERBFI) != 0)
|
} else if (fifo_numchars(&vu->rxfifo) > 0 && (vu->ier & IER_ERBFI) != 0) {
|
||||||
return IIR_RXTOUT;
|
return IIR_RXTOUT;
|
||||||
else if (vu->thre_int_pending && (vu->ier & IER_ETBEI) != 0)
|
} else if (vu->thre_int_pending && (vu->ier & IER_ETBEI) != 0) {
|
||||||
return IIR_TXRDY;
|
return IIR_TXRDY;
|
||||||
else
|
} else {
|
||||||
return IIR_NOPEND;
|
return IIR_NOPEND;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void uart_init(struct vuart *vu)
|
static void uart_init(struct vuart *vu)
|
||||||
{
|
{
|
||||||
@ -136,12 +138,14 @@ static void uart_toggle_intr(struct vuart *vu)
|
|||||||
intr_reason = uart_intr_reason(vu);
|
intr_reason = uart_intr_reason(vu);
|
||||||
|
|
||||||
if (intr_reason != IIR_NOPEND) {
|
if (intr_reason != IIR_NOPEND) {
|
||||||
if (vu->vm->vpic != NULL)
|
if (vu->vm->vpic != NULL) {
|
||||||
vpic_assert_irq(vu->vm, COM1_IRQ);
|
vpic_assert_irq(vu->vm, COM1_IRQ);
|
||||||
|
}
|
||||||
|
|
||||||
vioapic_assert_irq(vu->vm, COM1_IRQ);
|
vioapic_assert_irq(vu->vm, COM1_IRQ);
|
||||||
if (vu->vm->vpic != NULL)
|
if (vu->vm->vpic != NULL) {
|
||||||
vpic_deassert_irq(vu->vm, COM1_IRQ);
|
vpic_deassert_irq(vu->vm, COM1_IRQ);
|
||||||
|
}
|
||||||
|
|
||||||
vioapic_deassert_irq(vu->vm, COM1_IRQ);
|
vioapic_deassert_irq(vu->vm, COM1_IRQ);
|
||||||
}
|
}
|
||||||
@ -189,8 +193,9 @@ static void uart_write(__unused struct vm_io_handler *hdlr,
|
|||||||
if ((value & FCR_FIFOE) == 0) {
|
if ((value & FCR_FIFOE) == 0) {
|
||||||
vu->fcr = 0;
|
vu->fcr = 0;
|
||||||
} else {
|
} else {
|
||||||
if ((value & FCR_RFR) != 0)
|
if ((value & FCR_RFR) != 0) {
|
||||||
fifo_reset(&vu->rxfifo);
|
fifo_reset(&vu->rxfifo);
|
||||||
|
}
|
||||||
|
|
||||||
vu->fcr = value &
|
vu->fcr = value &
|
||||||
(FCR_FIFOE | FCR_DMA | FCR_RX_MASK);
|
(FCR_FIFOE | FCR_DMA | FCR_RX_MASK);
|
||||||
@ -262,8 +267,9 @@ static uint32_t uart_read(__unused struct vm_io_handler *hdlr,
|
|||||||
/*
|
/*
|
||||||
* Deal with side effects of reading the IIR register
|
* Deal with side effects of reading the IIR register
|
||||||
*/
|
*/
|
||||||
if (intr_reason == IIR_TXRDY)
|
if (intr_reason == IIR_TXRDY) {
|
||||||
vu->thre_int_pending = false;
|
vu->thre_int_pending = false;
|
||||||
|
}
|
||||||
iir |= intr_reason;
|
iir |= intr_reason;
|
||||||
reg = iir;
|
reg = iir;
|
||||||
break;
|
break;
|
||||||
@ -277,10 +283,11 @@ static uint32_t uart_read(__unused struct vm_io_handler *hdlr,
|
|||||||
/* Transmitter is always ready for more data */
|
/* Transmitter is always ready for more data */
|
||||||
vu->lsr |= LSR_TEMT | LSR_THRE;
|
vu->lsr |= LSR_TEMT | LSR_THRE;
|
||||||
/* Check for new receive data */
|
/* Check for new receive data */
|
||||||
if (fifo_numchars(&vu->rxfifo) > 0)
|
if (fifo_numchars(&vu->rxfifo) > 0) {
|
||||||
vu->lsr |= LSR_DR;
|
vu->lsr |= LSR_DR;
|
||||||
else
|
} else {
|
||||||
vu->lsr &= ~LSR_DR;
|
vu->lsr &= ~LSR_DR;
|
||||||
|
}
|
||||||
reg = vu->lsr;
|
reg = vu->lsr;
|
||||||
/* The LSR_OE bit is cleared on LSR read */
|
/* The LSR_OE bit is cleared on LSR read */
|
||||||
vu->lsr &= ~LSR_OE;
|
vu->lsr &= ~LSR_OE;
|
||||||
@ -318,8 +325,9 @@ void vuart_console_tx_chars(void)
|
|||||||
struct vuart *vu;
|
struct vuart *vu;
|
||||||
|
|
||||||
vu = vuart_console_active();
|
vu = vuart_console_active();
|
||||||
if (vu == NULL)
|
if (vu == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vuart_lock(vu);
|
vuart_lock(vu);
|
||||||
while (fifo_numchars(&vu->txfifo) > 0) {
|
while (fifo_numchars(&vu->txfifo) > 0) {
|
||||||
@ -342,8 +350,9 @@ void vuart_console_rx_chars(uint32_t serial_handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vu = vuart_console_active();
|
vu = vuart_console_active();
|
||||||
if (vu == NULL)
|
if (vu == NULL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
vuart_lock(vu);
|
vuart_lock(vu);
|
||||||
/* Get data from serial */
|
/* Get data from serial */
|
||||||
@ -377,9 +386,10 @@ struct vuart *vuart_console_active(void)
|
|||||||
if ((vm != NULL) && (vm->vuart != NULL)) {
|
if ((vm != NULL) && (vm->vuart != NULL)) {
|
||||||
struct vuart *vu = vm->vuart;
|
struct vuart *vu = vm->vuart;
|
||||||
|
|
||||||
if (vu->active)
|
if (vu->active) {
|
||||||
return vm->vuart;
|
return vm->vuart;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,20 +63,23 @@ static inline uint32_t io_read_long(uint16_t port)
|
|||||||
|
|
||||||
static inline void io_write(uint32_t v, uint16_t addr, size_t sz)
|
static inline void io_write(uint32_t v, uint16_t addr, size_t sz)
|
||||||
{
|
{
|
||||||
if (sz == 1U)
|
if (sz == 1U) {
|
||||||
io_write_byte((uint8_t)v, addr);
|
io_write_byte((uint8_t)v, addr);
|
||||||
else if (sz == 2U)
|
} else if (sz == 2U) {
|
||||||
io_write_word((uint16_t)v, addr);
|
io_write_word((uint16_t)v, addr);
|
||||||
else
|
} else {
|
||||||
io_write_long(v, addr);
|
io_write_long(v, addr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint32_t io_read(uint16_t addr, size_t sz)
|
static inline uint32_t io_read(uint16_t addr, size_t sz)
|
||||||
{
|
{
|
||||||
if (sz == 1U)
|
if (sz == 1U) {
|
||||||
return io_read_byte(addr);
|
return io_read_byte(addr);
|
||||||
if (sz == 2U)
|
}
|
||||||
|
if (sz == 2U) {
|
||||||
return io_read_word(addr);
|
return io_read_word(addr);
|
||||||
|
}
|
||||||
return io_read_long(addr);
|
return io_read_long(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +78,13 @@ struct trace_entry {
|
|||||||
static inline bool
|
static inline bool
|
||||||
trace_check(uint16_t cpu_id, __unused uint32_t evid)
|
trace_check(uint16_t cpu_id, __unused uint32_t evid)
|
||||||
{
|
{
|
||||||
if (cpu_id >= phys_cpu_num)
|
if (cpu_id >= phys_cpu_num) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (per_cpu(sbuf, cpu_id)[ACRN_TRACE] == NULL)
|
if (per_cpu(sbuf, cpu_id)[ACRN_TRACE] == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -107,8 +109,9 @@ TRACE_2L(uint32_t evid, uint64_t e, uint64_t f)
|
|||||||
struct trace_entry entry;
|
struct trace_entry entry;
|
||||||
uint16_t cpu_id = get_cpu_id();
|
uint16_t cpu_id = get_cpu_id();
|
||||||
|
|
||||||
if (!trace_check(cpu_id, evid))
|
if (!trace_check(cpu_id, evid)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entry.payload.fields_64.e = e;
|
entry.payload.fields_64.e = e;
|
||||||
entry.payload.fields_64.f = f;
|
entry.payload.fields_64.f = f;
|
||||||
@ -122,8 +125,9 @@ TRACE_4I(uint32_t evid, uint32_t a, uint32_t b, uint32_t c,
|
|||||||
struct trace_entry entry;
|
struct trace_entry entry;
|
||||||
uint16_t cpu_id = get_cpu_id();
|
uint16_t cpu_id = get_cpu_id();
|
||||||
|
|
||||||
if (!trace_check(cpu_id, evid))
|
if (!trace_check(cpu_id, evid)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entry.payload.fields_32.a = a;
|
entry.payload.fields_32.a = a;
|
||||||
entry.payload.fields_32.b = b;
|
entry.payload.fields_32.b = b;
|
||||||
@ -139,8 +143,9 @@ TRACE_6C(uint32_t evid, uint8_t a1, uint8_t a2, uint8_t a3,
|
|||||||
struct trace_entry entry;
|
struct trace_entry entry;
|
||||||
uint16_t cpu_id = get_cpu_id();
|
uint16_t cpu_id = get_cpu_id();
|
||||||
|
|
||||||
if (!trace_check(cpu_id, evid))
|
if (!trace_check(cpu_id, evid)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entry.payload.fields_8.a1 = a1;
|
entry.payload.fields_8.a1 = a1;
|
||||||
entry.payload.fields_8.a2 = a2;
|
entry.payload.fields_8.a2 = a2;
|
||||||
@ -162,8 +167,9 @@ TRACE_16STR(uint32_t evid, const char name[])
|
|||||||
uint16_t cpu_id = get_cpu_id();
|
uint16_t cpu_id = get_cpu_id();
|
||||||
size_t len, i;
|
size_t len, i;
|
||||||
|
|
||||||
if (!trace_check(cpu_id, evid))
|
if (!trace_check(cpu_id, evid)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entry.payload.fields_64.e = 0UL;
|
entry.payload.fields_64.e = 0UL;
|
||||||
entry.payload.fields_64.f = 0UL;
|
entry.payload.fields_64.f = 0UL;
|
||||||
|
@ -66,8 +66,9 @@
|
|||||||
static inline uint16_t fls32(uint32_t value)
|
static inline uint16_t fls32(uint32_t value)
|
||||||
{
|
{
|
||||||
uint32_t ret = 0U;
|
uint32_t ret = 0U;
|
||||||
if (value == 0U)
|
if (value == 0U) {
|
||||||
return (INVALID_BIT_INDEX);
|
return (INVALID_BIT_INDEX);
|
||||||
|
}
|
||||||
asm volatile("bsrl %1,%0"
|
asm volatile("bsrl %1,%0"
|
||||||
: "=r" (ret)
|
: "=r" (ret)
|
||||||
: "rm" (value));
|
: "rm" (value));
|
||||||
@ -77,8 +78,9 @@ static inline uint16_t fls32(uint32_t value)
|
|||||||
static inline uint16_t fls64(uint64_t value)
|
static inline uint16_t fls64(uint64_t value)
|
||||||
{
|
{
|
||||||
uint64_t ret = 0UL;
|
uint64_t ret = 0UL;
|
||||||
if (value == 0UL)
|
if (value == 0UL) {
|
||||||
return (INVALID_BIT_INDEX);
|
return (INVALID_BIT_INDEX);
|
||||||
|
}
|
||||||
asm volatile("bsrq %1,%0"
|
asm volatile("bsrq %1,%0"
|
||||||
: "=r" (ret)
|
: "=r" (ret)
|
||||||
: "rm" (value));
|
: "rm" (value));
|
||||||
@ -113,8 +115,9 @@ static inline uint16_t fls64(uint64_t value)
|
|||||||
static inline uint16_t ffs64(uint64_t value)
|
static inline uint16_t ffs64(uint64_t value)
|
||||||
{
|
{
|
||||||
uint64_t ret = 0UL;
|
uint64_t ret = 0UL;
|
||||||
if (value == 0UL)
|
if (value == 0UL) {
|
||||||
return (INVALID_BIT_INDEX);
|
return (INVALID_BIT_INDEX);
|
||||||
|
}
|
||||||
asm volatile("bsfq %1,%0"
|
asm volatile("bsfq %1,%0"
|
||||||
: "=r" (ret)
|
: "=r" (ret)
|
||||||
: "rm" (value));
|
: "rm" (value));
|
||||||
@ -144,9 +147,9 @@ static inline uint16_t ffz64(uint64_t value)
|
|||||||
*/
|
*/
|
||||||
static inline uint16_t clz(uint32_t value)
|
static inline uint16_t clz(uint32_t value)
|
||||||
{
|
{
|
||||||
if (value == 0U)
|
if (value == 0U) {
|
||||||
return 32U;
|
return 32U;
|
||||||
else{
|
} else {
|
||||||
return (31U - fls32(value));
|
return (31U - fls32(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,9 +163,9 @@ static inline uint16_t clz(uint32_t value)
|
|||||||
*/
|
*/
|
||||||
static inline uint16_t clz64(uint64_t value)
|
static inline uint16_t clz64(uint64_t value)
|
||||||
{
|
{
|
||||||
if (value == 0UL)
|
if (value == 0UL) {
|
||||||
return 64U;
|
return 64U;
|
||||||
else{
|
} else {
|
||||||
return (63U - fls64(value));
|
return (63U - fls64(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,10 @@ static inline void __list_splice(struct list_head *list,
|
|||||||
|
|
||||||
static inline void list_splice(struct list_head *list, struct list_head *head)
|
static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||||
{
|
{
|
||||||
if (!list_empty(list))
|
if (!list_empty(list)) {
|
||||||
__list_splice(list, head);
|
__list_splice(list, head);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void list_splice_init(struct list_head *list,
|
static inline void list_splice_init(struct list_head *list,
|
||||||
struct list_head *head)
|
struct list_head *head)
|
||||||
|
@ -88,8 +88,9 @@ int udiv64(uint64_t dividend, uint64_t divisor, struct udiv_result *res)
|
|||||||
/* simplified case: only 32 bit operands Note that the preconditions
|
/* simplified case: only 32 bit operands Note that the preconditions
|
||||||
* for do_udiv32() are fulfilled, since the tests were made above.
|
* for do_udiv32() are fulfilled, since the tests were made above.
|
||||||
*/
|
*/
|
||||||
if (((divisor >> 32UL) == 0UL) && ((dividend >> 32UL) == 0UL))
|
if (((divisor >> 32UL) == 0UL) && ((dividend >> 32UL) == 0UL)) {
|
||||||
return do_udiv32((uint32_t) dividend, (uint32_t) divisor, res);
|
return do_udiv32((uint32_t) dividend, (uint32_t) divisor, res);
|
||||||
|
}
|
||||||
|
|
||||||
/* dividend is always greater than or equal to the divisor. Neither
|
/* dividend is always greater than or equal to the divisor. Neither
|
||||||
* divisor nor dividend are 0. Thus: * clz(dividend) and clz(divisor)
|
* divisor nor dividend are 0. Thus: * clz(dividend) and clz(divisor)
|
||||||
|
Loading…
Reference in New Issue
Block a user