From ae742fffaac7ea1a7256d1dbaab384b8fed62b90 Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Wed, 21 Apr 2021 01:37:47 -0500 Subject: [PATCH] Minor cleanup --- kestrel/src/kestrel.c | 18 ++++++++++++++---- kestrel/src/kestrel.h | 4 ++-- kestrel/src/shell.c | 2 +- prj.conf | 4 +++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/kestrel/src/kestrel.c b/kestrel/src/kestrel.c index a2436f6..71b3c82 100644 --- a/kestrel/src/kestrel.c +++ b/kestrel/src/kestrel.c @@ -1452,6 +1452,9 @@ static int process_host_to_bmc_ipmi_bt_transactions(void) } #if (ENABLE_LPC_FW_CYCLE_DMA) + // Deactivate interrupts on entering critical section + int key = irq_lock(); + // Disable DMA engine dword = read_aquila_register(HOSTLPCSLAVE_BASE, AQUILA_LPC_REG_DMA_CONFIG1); dword &= ~((1 & AQUILA_LPC_CTL_EN_FW_DMA_R_MASK) << AQUILA_LPC_CTL_EN_FW_DMA_R_SHIFT); @@ -1512,6 +1515,9 @@ static int process_host_to_bmc_ipmi_bt_transactions(void) dword &= ~((1 & AQUILA_LPC_CTL_EN_FW_DMA_W_MASK) << AQUILA_LPC_CTL_EN_FW_DMA_W_SHIFT); } write_aquila_register(HOSTLPCSLAVE_BASE, AQUILA_LPC_REG_DMA_CONFIG1, dword); + + // Re-activate interupts on exiting critical section + irq_unlock(key); #endif // Generate response @@ -1701,10 +1707,12 @@ static int process_interrupts_stage2(void) int read_position; int work_executed; +#if (WITH_ZEPHYR) if (k_mutex_lock(&vuart1_access_mutex, K_MSEC(100)) != 0) { printk("Unable to acquire VUART1 mutex in a timely manner! %s:%d\n", __FILE__, __LINE__); return -EAGAIN; } +#endif work_executed = 0; @@ -2759,6 +2767,7 @@ int host_console_event_loop(const struct shell *shell) } if (chars_to_tx > 0) { + chars_sent = 0; if (shell->iface->api->write(shell->iface, vuart1_incoming_buffer + vuart1_incoming_buffer_read_pos, chars_to_tx, &chars_sent) == 0) { if (chars_sent > 0) { vuart1_incoming_buffer_read_pos += chars_sent; @@ -2783,8 +2792,10 @@ int host_console_event_loop(const struct shell *shell) } int attach_to_host_console(const struct shell *shell) { - // Deactivate interrupts on entering critical section - int key = irq_lock(); + if (k_mutex_lock(&vuart1_access_mutex, K_MSEC(100)) != 0) { + printk("Unable to acquire VUART1 mutex in a timely manner! %s:%d\n", __FILE__, __LINE__); + return -EAGAIN; + } // Reset VUART1 ring buffer pointers vuart1_outgoing_buffer_read_pos = vuart1_outgoing_buffer_write_pos; @@ -2793,8 +2804,7 @@ int attach_to_host_console(const struct shell *shell) host_console_service_task_requested = 1; host_console_service_task_shell = shell; - // Re-activate interupts on exiting critical section - irq_unlock(key); + k_mutex_unlock(&vuart1_access_mutex); return 0; } diff --git a/kestrel/src/kestrel.h b/kestrel/src/kestrel.h index 0aa57bf..ca321a8 100644 --- a/kestrel/src/kestrel.h +++ b/kestrel/src/kestrel.h @@ -8,7 +8,7 @@ #endif #if (WITH_ZEPHYR) -#define KESTREL_SERVICE_THREAD_PRIORITY K_PRIO_COOP(1) +#define KESTREL_SERVICE_THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NUM_PREEMPT_PRIORITIES - 1) #endif struct firmware_buffer_region { @@ -44,4 +44,4 @@ int attach_to_host_console(const struct shell *shell); int host_console_event_loop(const struct shell *shell); #else int attach_to_host_console(); -#endif \ No newline at end of file +#endif diff --git a/kestrel/src/shell.c b/kestrel/src/shell.c index 39d38bf..84c0168 100644 --- a/kestrel/src/shell.c +++ b/kestrel/src/shell.c @@ -220,4 +220,4 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_kestrel, ); // Register main kestrel command prefix -SHELL_CMD_REGISTER(kestrel, &sub_kestrel, "Kestrel commands", NULL); \ No newline at end of file +SHELL_CMD_REGISTER(kestrel, &sub_kestrel, "Kestrel commands", NULL); diff --git a/prj.conf b/prj.conf index f373e50..95031a4 100644 --- a/prj.conf +++ b/prj.conf @@ -42,10 +42,12 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=100663296 # Logging settings +#CONFIG_LOG_MODE_MINIMAL=y CONFIG_LOG_MODE_IMMEDIATE=y +#CONFIG_LOG_MODE_DEFERRED=y CONFIG_LOG_RUNTIME_FILTERING=y CONFIG_LOG_BUFFER_SIZE=1024 -CONFIG_LOG_PRINTK=y +CONFIG_LOG_PRINTK=n CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD=0 # POSIX options -- 2.30.2