Mercurial > hg > Members > menikon > CbC_xv6
changeset 66:101b229f182d cmake
build initcode
author | anatofuz |
---|---|
date | Fri, 26 Jul 2019 19:24:31 +0900 |
parents | 2fdcb0f953bb |
children | 08a29b29d290 |
files | src/CMakeLists.txt src/gearsTools/pmake.pl |
diffstat | 2 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/CMakeLists.txt Fri Jul 26 18:46:36 2019 +0900 +++ b/src/CMakeLists.txt Fri Jul 26 19:24:31 2019 +0900 @@ -3,6 +3,7 @@ set(BUILD_DIR ${PROJECT_BINARY_DIR}) add_subdirectory(tools) add_subdirectory(usr) +enable_language(C ASM) set(USE_CUDA,0) @@ -35,6 +36,7 @@ configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY) macro( GearsCommand ) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL") set(CMAKE_C_COMPILER "${CBC_COM}") set(CMAKE_LINKER "${X_CMAKE_LINKER}") set(CMAKE_C_LINK_EXECUTABLE "${X_CMAKE_C_LINK_EXECUTABLE}") @@ -71,14 +73,22 @@ #target_link_libraries(syslib) add_custom_command ( OUTPUT c/${_Gears_TARGET}-context.c - DEPENDS ${_Gears_CBC_SOURCES} fs.img + DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode COMMAND "perl" "gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES} ) add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c ) # target_link_libraries(${_Gears_TARGET} m pthread) endmacro() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL") + +set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}") +set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}") +add_executable(initcode.o initcode.S) +add_custom_command( + OUTPUT initcode + DEPENDS initcode.o + COMMAND "arm-none-eabi-objcopy" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "initcode.o" "initcode" +) GearsCommand ( TARGET
--- a/src/gearsTools/pmake.pl Fri Jul 26 18:46:36 2019 +0900 +++ b/src/gearsTools/pmake.pl Fri Jul 26 19:24:31 2019 +0900 @@ -2,7 +2,7 @@ use strict; use warnings; -my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake,$kernel_cflags,$kernel_ld_flags,$kernel_ld_command); +my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake,$kernel_cflags,$kernel_ld_flags,$kernel_ld_command, $initcode_cflags, $initcode_ld_command); $cmake = 'cmake'; @@ -28,12 +28,25 @@ # -DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode usr/fs.img\" $kernel_ld_flags = ' -L. -N -e main -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L ../ /mnt/dalmore-home/one/src/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/libgcc.a'; $kernel_ld_command = "$ld $kernel_ld_flags"; + $initcode_cflags = '-march=armv6 -nostdinc -I. -c'; + $initcode_ld_command = "$ld -L. -N -e start -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"; } $cflags =~ s/\n//g; create_link_script(); -print_exec_system($cmake, "-DGCC_LIB=$libgcc", "-DCBC_COM=$cc", "-DPMAKE_ARGS=\"$cflags\"","-DCMAKE_ASM_COMPILER=$cc","-DX_CMAKE_LINKER=$ld","-DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode fs.img\"","-DKERNEL_LINK_EXECUTABLE=\"$kernel_ld_command\"","-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE",@ARGV); +print_exec_system($cmake, + "-DGCC_LIB=$libgcc", + "-DCBC_COM=$cc", + "-DPMAKE_ARGS=\"$cflags\"", + "-DCMAKE_ASM_COMPILER=$cc", + "-DX_CMAKE_LINKER=$ld", + "-DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode fs.img\"", + "-DKERNEL_LINK_EXECUTABLE=\"$kernel_ld_command\"", + "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE", + "-DINITOCDE_CFLAGS=\"$initcode_cflags\"", + "-DINITOCDE_LINK_EXECUTABLE=\"$initcode_ld_command\"", +@ARGV); system("make"); #system("sh","link.sh");