diff --git a/kestrel/src/kestrel.c b/kestrel/src/kestrel.c index a2436f698c3dfd1df4cbafa8ee1e943ec81b2a72..71b3c827a60d2a88a9aa657da8fbfe4acf312498 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 0aa57bf1bdad122922dbadfadcbe6a89e713b41b..ca321a8ddd29ad4e87f4eb6472fa936c9a59cda9 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 39d38bfc000cf2cee1afe2529a1d848efd67f25f..84c01684247fc39fa2ffd4b6854a41e4b280e397 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 f373e504b0989d60e9372d76ba8ea3d76e21c73d..95031a43c3e650bcc214f5a9532f8a2b083fd56c 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