From a93f257f2e449aba9beb39c43d4e097e673436c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilja=20Karta=C5=A1ov?= Date: Fri, 17 Jan 2020 10:13:01 +0100 Subject: [PATCH] Repair compilability of code --- kernel/Makefile | 1 - kernel/aarch64/aarch64.S | 8 ++++---- kernel/aarch64/aarch64_boot.S | 2 +- kernel/drivers/timer/timer.c | 26 +++++++++++++++++++------- kernel/drivers/timer/timer.h | 4 ++-- kernel/drivers/uart/uart_mini.c | 8 ++++---- kernel/leos/arch.h | 2 +- kernel/leos/irq.c | 4 ++-- kernel/leos/leos.c | 4 ++-- kernel/leos/log.c | 12 ++++++------ kernel/leos/log.h | 2 +- kernel/leos/memory.c | 2 +- kernel/leos/task.c | 23 +++++++++++++++++++++++ kernel/leos/task.h | 8 +++++++- 14 files changed, 73 insertions(+), 33 deletions(-) create mode 100644 kernel/leos/task.c diff --git a/kernel/Makefile b/kernel/Makefile index 809ab0e..e2fc240 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -29,7 +29,6 @@ SOURCE_FILES = \ leos/leos.c \ leos/log.c \ leos/memory.c \ - leos/scheduler.c \ leos/task.c \ \ drivers/timer/timer.c \ diff --git a/kernel/aarch64/aarch64.S b/kernel/aarch64/aarch64.S index abd010f..e416a0a 100644 --- a/kernel/aarch64/aarch64.S +++ b/kernel/aarch64/aarch64.S @@ -1,4 +1,4 @@ -#include "AArch64_irq.h" +#include "aarch64_irq.h" .globl AArch64_init AArch64_init: @@ -15,19 +15,19 @@ AArch64_getEL: ret .globl AArch64_getReg32 -AArch64_get32r: +AArch64_getReg32: ldr w0, [x0] ret .globl AArch64_setReg32 -AArch64_set32r: +AArch64_setReg32: str w1, [x0] ret .globl AArch64_idle AArch64_idle: subs x0, x0, 1 - bne AArch64_delay + bne AArch64_idle ret /* diff --git a/kernel/aarch64/aarch64_boot.S b/kernel/aarch64/aarch64_boot.S index be89c4a..74ccc7b 100644 --- a/kernel/aarch64/aarch64_boot.S +++ b/kernel/aarch64/aarch64_boot.S @@ -35,7 +35,7 @@ set_stack: mov sp, x30 bl skip skip: - bl k_main + bl Leos_run hang: b hang diff --git a/kernel/drivers/timer/timer.c b/kernel/drivers/timer/timer.c index 6f66d7e..92d864e 100644 --- a/kernel/drivers/timer/timer.c +++ b/kernel/drivers/timer/timer.c @@ -14,28 +14,40 @@ */ #include -#include +#include +#include #include "timer.h" -#include "log.h" const unsigned int m_interval = 200000; unsigned int m_current = 0; +#ifndef CONFIG_ARM_TIMER +#define CONFIG_ARM_TIMER 1 +#endif + void -k_timer_init(void) +Timer_init(void) { +#if CONFIG_ARM_TIMER == 1 +#else m_current = aarch64_get32r(TIMER_CLO); m_current += m_interval; aarch64_set32r(TIMER_C1, m_current); +#endif } void -k_timer_irq_handler(void) +Timer_incFromISR(void) { +#if CONFIG_ARM_TIMER == 1 + +#else m_current += m_interval; aarch64_set32r(TIMER_C1, m_current); aarch64_set32r(TIMER_CS, TIMER_CS_M1); - k_logs("Timer: "); - k_logu(m_current, 10); - k_logs("\r\n"); +#endif + Log_putS("Timer: "); + Log_putI(m_current, 10); + Log_putS("\r\n"); } + diff --git a/kernel/drivers/timer/timer.h b/kernel/drivers/timer/timer.h index 389b254..c75bbf0 100644 --- a/kernel/drivers/timer/timer.h +++ b/kernel/drivers/timer/timer.h @@ -17,9 +17,9 @@ #define TIMER_H_8D327261_47D6_4832_8DC5_31BF1614A21F void -k_timer_init(void); +Timer_init(void); void -k_timer_irq_handler(void); +Timer_incFromISR(void); #endif /* !TIMER_H */ diff --git a/kernel/drivers/uart/uart_mini.c b/kernel/drivers/uart/uart_mini.c index 673942f..9031bb0 100644 --- a/kernel/drivers/uart/uart_mini.c +++ b/kernel/drivers/uart/uart_mini.c @@ -14,9 +14,9 @@ */ #include -#include +#include -#include "UARTMini.h" +#include "uart_mini.h" int @@ -49,9 +49,9 @@ UARTMini_init(void) AArch64_setReg32(GPFSEL1, sel); AArch64_setReg32(GPPUD, 0); - AArch64_delay(150); + AArch64_idle(150); AArch64_setReg32(GPPUDCLK0, (1 << 14) | (1 << 15)); - AArch64_delay(150); + AArch64_idle(150); AArch64_setReg32(GPPUDCLK0, 0); /* Enable TX and RX */ diff --git a/kernel/leos/arch.h b/kernel/leos/arch.h index 30ab40d..144e012 100644 --- a/kernel/leos/arch.h +++ b/kernel/leos/arch.h @@ -18,6 +18,6 @@ #include -#define k_arch_init(...) aarch64_init(__VA_ARGS__) +#define Arch_init(...) AArch64_init(__VA_ARGS__) #endif /* !ARCH_H */ diff --git a/kernel/leos/irq.c b/kernel/leos/irq.c index 6a38752..0f735b7 100644 --- a/kernel/leos/irq.c +++ b/kernel/leos/irq.c @@ -13,8 +13,8 @@ * @see https://lowenware.com/ */ -#include -#include "timer.h" +#include +#include #include "log.h" #include "task.h" #include "irq.h" diff --git a/kernel/leos/leos.c b/kernel/leos/leos.c index a89d74c..a45cc3e 100644 --- a/kernel/leos/leos.c +++ b/kernel/leos/leos.c @@ -16,8 +16,8 @@ #include #include #include -#include #include +#include void @@ -29,7 +29,7 @@ Leos_run(void) Log_putI(AArch64_getEL(), 10); Log_putS(")\r\n"); - Arch_init(); + AArch64_init(); Timer_init(); IRQ_init(); diff --git a/kernel/leos/log.c b/kernel/leos/log.c index 634f46a..73b0f6c 100644 --- a/kernel/leos/log.c +++ b/kernel/leos/log.c @@ -13,7 +13,7 @@ * @see https://lowenware.com/ */ -#include +#include #include "log.h" void @@ -28,7 +28,7 @@ Log_putS(const char *string) char c; const char *p = string; while((c = *p) != 0) { - if (UART_send(c)) + if (UART_put(c)) return -1; p++; } @@ -41,14 +41,14 @@ Log_putI(int64_t value, uint8_t base) int result; if (value < 0) { - if (UART_send('-')) + if (UART_put('-')) return -1; value = -value; result = 1; } else { result = 0; } - result += k_logu(value, base); + result += Log_putU(value, base); return (result) ? result : -1; } @@ -59,7 +59,7 @@ Log_putU(uint64_t value, uint8_t base) char buffer[64]; if (!value) { - return (UART_send('0')) ? -1 : 1; + return (UART_put('0')) ? -1 : 1; } do { @@ -75,7 +75,7 @@ Log_putU(uint64_t value, uint8_t base) result = i; while (i--) { - if (UART_send(buffer[i])) + if (UART_put(buffer[i])) return -1; } return result; diff --git a/kernel/leos/log.h b/kernel/leos/log.h index 22ca81a..b632167 100644 --- a/kernel/leos/log.h +++ b/kernel/leos/log.h @@ -16,7 +16,7 @@ #ifndef LOG_H_AE38CD54_2822_47A5_AFB1_E785739FA01D #define LOG_H_AE38CD54_2822_47A5_AFB1_E785739FA01D -#include +#include void Log_init(void); diff --git a/kernel/leos/memory.c b/kernel/leos/memory.c index 5ce8b1e..f9b6a0f 100644 --- a/kernel/leos/memory.c +++ b/kernel/leos/memory.c @@ -15,7 +15,7 @@ */ #include -#include +#include #include "memory.h" static unsigned long m_map[MEMORY_PAGE_COUNT / sizeof(unsigned long) / 8] = {0,}; diff --git a/kernel/leos/task.c b/kernel/leos/task.c new file mode 100644 index 0000000..afb373b --- /dev/null +++ b/kernel/leos/task.c @@ -0,0 +1,23 @@ +/****************************************************************************** + * + * Copyright (c) 2017-2020 by Löwenware Ltd + * Please, refer LICENSE file for legal information + * + ******************************************************************************/ + +/** + * @file task.c + * @author Ilja Kartašov + * @brief + * + * @see https://lowenware.com/ + */ + +#include "task.h" + + +unsigned long +Task_scheduleFromISR(void) +{ + return 0; +} diff --git a/kernel/leos/task.h b/kernel/leos/task.h index 4145d62..be050ed 100644 --- a/kernel/leos/task.h +++ b/kernel/leos/task.h @@ -16,7 +16,11 @@ #ifndef TASK_H_AE13C166_79B5_4256_ABF3_74DF04E1CD18 #define TASK_H_AE13C166_79B5_4256_ABF3_74DF04E1CD18 -#include +#include + +#ifndef CONFIG_TASK_MAX_NAME_LEN +#define CONFIG_TASK_MAX_NAME_LEN 16 +#endif typedef void (*TaskCallback)(void *p_ctx); @@ -32,5 +36,7 @@ PID Task_create(struct Task *pTask, TaskCallback callback, uint64_t *stack , uint32_t stack_size); +unsigned long +Task_scheduleFromISR(void); #endif /* !TASK_H */