Skip to content

Commit

Permalink
added kconfig for ca9 and ca53, merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
chungae9ri committed Jun 6, 2024
1 parent 7759f9b commit 4f2d2b7
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": "--soc zynq-7000"
/*"args": "--soc zynq-7000"*/
"args": "--defconfig zynq7000_defconfig"
},
{
"name": "C/C++: arm-none-eabi-gcc build and debug active file",
Expand Down
6 changes: 2 additions & 4 deletions kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ message("generate kconfig defs")
add_custom_command(
OUTPUT ${kconfig_defs_fname}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/generated
COMMAND ${CMAKE_COMMAND} -E env python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen_kconfig_defs.py > ${CMAKE_BINARY_DIR}/generated/${kconfig_defs_fname}
COMMAND ${CMAKE_COMMAND} -E env python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen_kconfig_defs.py --defconfig zynqmp_defconfig > ${CMAKE_BINARY_DIR}/generated/${kconfig_defs_fname}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen_kconfig_defs.py
)

Expand All @@ -63,13 +63,11 @@ add_compile_options(-DAARCH64=1)

add_subdirectory(arch/ca-53)
add_subdirectory(core)
add_subdirectory(core64)
add_subdirectory(drivers)

add_executable(
${TARGET_NAME}
$<TARGET_OBJECTS:arch_objs>
$<TARGET_OBJECTS:core64_objs>
$<TARGET_OBJECTS:core_objs>
$<TARGET_OBJECTS:drivers_objs>
)
Expand All @@ -93,7 +91,7 @@ message("generate kconfig defs")
add_custom_command(
OUTPUT ${kconfig_defs_fname}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/generated
COMMAND ${CMAKE_COMMAND} -E env python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen_kconfig_defs.py > ${CMAKE_BINARY_DIR}/generated/${kconfig_defs_fname}
COMMAND ${CMAKE_COMMAND} -E env python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen_kconfig_defs.py --defconfig zynq7000_defconfig > ${CMAKE_BINARY_DIR}/generated/${kconfig_defs_fname}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen_kconfig_defs.py
)

Expand Down
17 changes: 12 additions & 5 deletions kernel/Kconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
menu "Main Menu"

config EXAMPLE_OPTION
bool "Example option"
default n
help
This is an example option.
config SOC_ZYNQ7000
bool "SOC is zynq7000"

config SOC_ZYNQMP
bool "SOC is zynqmp"
endmenu

if SOC_ZYNQ7000
source "arch/ca-9/Kconfig"
endif

if SOC_ZYNQMP
source "arch/ca-53/Kconfig"
endif
9 changes: 9 additions & 0 deletions kernel/arch/ca-53/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
menu "CA53 Arch"

config ARCH_CORTEX_A53
bool "Cortex-A53 architecture"
default y
help
Cortex-A53 architecture

endmenu
9 changes: 9 additions & 0 deletions kernel/arch/ca-9/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
menu "CA9 Arch"

config ARCH_CORTEX_A9
bool "Cortex-A9 architecture"
default y
help
Cortex-A9 architecture

endmenu
1 change: 1 addition & 0 deletions kernel/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
if (TARGET_ARCH STREQUAL "aarch64")
add_library(
core_objs OBJECT
main.c
printk.c
)
else ()
Expand Down
25 changes: 24 additions & 1 deletion kernel/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
//
// Copyright (c) 2024 kwangdo.yi<kwangdo.yi@gmail.com>

#include <printk.h>
#include <generated_kconfig_defs.h>

#if defined(ARCH_CORTEX_A9)
#include <gic.h>
#include <ktimer.h>
#include <timer.h>
Expand All @@ -19,8 +21,12 @@
#include <mailbox.h>
#include <slfs.h>
#include <uart.h>
#endif

#include <printk.h>
#include <uart.h>

#if defined(ARCH_CORTEX_A9)
extern uint32_t show_stat;
extern void secondary_reset(void);
extern void flush_ent_dcache(void);
Expand Down Expand Up @@ -183,3 +189,20 @@ int start_kernel(void)

return 0;
}
#elif defined (ARCH_CORTEX_A53)

int main(void)
{
uint32_t current_el= 0;
init_uart();

/* read currentEL*/
asm volatile ("mrs %[cel], CurrentEL" : [cel] "=r" (current_el)::);
printk("currentEL: 0x%x\n", current_el >> 2);

while (1) ;

return 0;
}
#endif

4 changes: 0 additions & 4 deletions kernel/core64/CMakeLists.txt

This file was deleted.

24 changes: 0 additions & 24 deletions kernel/core64/main64.c

This file was deleted.

1 change: 0 additions & 1 deletion kernel/defconfig

This file was deleted.

25 changes: 17 additions & 8 deletions kernel/scripts/gen_kconfig_defs.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import kconfiglib # pip install kconfiglib
import os
import argparse

def main():
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--defconfig', type=str, required=True, default='zynq7000_defconfig')
args = parser.parse_args()

defconfig = args.defconfig

script_dir = os.path.dirname(os.path.abspath(__file__))
kconfig_path = os.path.join(script_dir, '../Kconfig')
def_path = os.path.join(script_dir, '../defconfig')
os.chdir(os.path.join(script_dir, '..'))

# Load the main Kconfig file
kconf = kconfiglib.Kconfig(kconfig_path)
kconf = kconfiglib.Kconfig("Kconfig")

# Load an existing configuration file
kconf.load_config(def_path)
ret = kconf.load_config(defconfig)

kconf.write_config(".config")

# use standard output redirection (>) to save the output config to C header
print("/* Auto-generated configuration header */\n")
Expand All @@ -19,15 +27,16 @@ def main():

for sym in kconf.unique_defined_syms:
if sym.str_value == "n":
print(f"#undef {sym.name}\n")
print(f"#undef {sym.name}")
elif sym.type in (kconfiglib.BOOL, kconfiglib.TRISTATE):
if sym.str_value == "y":
print(f"#define {sym.name} 1\n")
print(f"#define {sym.name} 1")
elif sym.type == kconfiglib.INT or sym.type == kconfiglib.STRING:
print(f"#define {sym.name} {sym.str_value}\n")
print(f"#define {sym.name} {sym.str_value}")
elif sym.type == kconfiglib.HEX:
print(f"#define {sym.name} 0x{sym.str_value}\n")
print(f"#define {sym.name} 0x{sym.str_value}")

print("\n")
print("#endif /* #ifndef GEN_KCONFIG_DEFS_H*/")

if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions kernel/zynq7000_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SOC_ZYNQ7000=y
1 change: 1 addition & 0 deletions kernel/zynqmp_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SOC_ZYNQMP=y

0 comments on commit 4f2d2b7

Please sign in to comment.