implement SuperH4 support, building with custom stdlib (libc)
This commit is contained in:
parent
011ead1a1c
commit
17bbc4af49
3 changed files with 68 additions and 5 deletions
|
|
@ -24,11 +24,15 @@ set(SOURCES
|
||||||
heap.c
|
heap.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(ARCHITECTURE "ARMv7" CACHE STRING "cutil target architecture")
|
set(ARCHITECTURE "SuperH4" CACHE STRING "cutil target architecture")
|
||||||
|
|
||||||
set(ARM_PROCESSOR "cortex-m4" CACHE STRING "cutil ARM processor")
|
set(ARM_PROCESSOR "cortex-m4" CACHE STRING "cutil ARM processor")
|
||||||
set(ARM_PROFILE "a" CACHE STRING "cutil ARM architecture profile")
|
set(ARM_PROFILE "a" CACHE STRING "cutil ARM architecture profile")
|
||||||
|
|
||||||
if ("${ARCHITECTURE}" MATCHES "ARM*")
|
if ("${ARCHITECTURE}" MATCHES "ARM*")
|
||||||
|
set(CUSTOM_STDLIB "" CACHE STRING "custom stdlib path")
|
||||||
|
add_compile_definitions(ARM_PROCESSOR="${ARM_PROCESSOR}")
|
||||||
|
add_compile_definitions(ARM_PROFILE="${ARM_PROFILE}")
|
||||||
if ("${ARM_PROFILE}" STREQUAL "m")
|
if ("${ARM_PROFILE}" STREQUAL "m")
|
||||||
add_compile_options("-mcpu=${ARM_PROCESSOR}")
|
add_compile_options("-mcpu=${ARM_PROCESSOR}")
|
||||||
add_compile_options("-mthumb")
|
add_compile_options("-mthumb")
|
||||||
|
|
@ -38,20 +42,28 @@ if ("${ARCHITECTURE}" MATCHES "ARM*")
|
||||||
add_compile_options("-march=${COMPILE_ARCHITECTURE}-${ARM_PROFILE}")
|
add_compile_options("-march=${COMPILE_ARCHITECTURE}-${ARM_PROFILE}")
|
||||||
add_compile_options("-marm")
|
add_compile_options("-marm")
|
||||||
endif()
|
endif()
|
||||||
|
elseif("${ARCHITECTURE}" MATCHES "SuperH4")
|
||||||
|
set(CUSTOM_STDLIB "/opt/sh4-platform/lib" CACHE STRING "custom stdlib path")
|
||||||
|
add_compile_options("-m4")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_compile_definitions(ARM_PROCESSOR="${ARM_PROCESSOR}")
|
|
||||||
add_compile_definitions(ARM_PROFILE="${ARM_PROFILE}")
|
|
||||||
|
|
||||||
add_library(cutil STATIC ${SOURCES} ${HEADERS}
|
add_library(cutil STATIC ${SOURCES} ${HEADERS}
|
||||||
"arch/${ARCHITECTURE}.S"
|
"arch/${ARCHITECTURE}.S"
|
||||||
)
|
)
|
||||||
|
|
||||||
option(NOSTDLIB "compile cutil without stdlib" ON)
|
option(NOSTDLIB "compile cutil without stdlib" ON)
|
||||||
|
option(STATIC "compile test static" OFF)
|
||||||
if (NOSTDLIB)
|
if (NOSTDLIB)
|
||||||
target_compile_definitions(cutil PRIVATE CUTIL_NOSTDLIB)
|
target_compile_definitions(cutil PRIVATE CUTIL_NOSTDLIB)
|
||||||
target_compile_options(cutil PRIVATE "-nostdlib")
|
target_compile_options(cutil PRIVATE "-nostdlib")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT "${CUSTOM_STDLIB}" STREQUAL "")
|
||||||
|
add_compile_options("-nostdlib")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-L${CUSTOM_STDLIB} -l:libc.so.6")
|
||||||
|
elseif (STATIC)
|
||||||
|
add_link_options(-static)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(test test.c)
|
add_executable(test test.c)
|
||||||
target_link_libraries(test -static cutil)
|
target_link_libraries(test cutil)
|
||||||
47
arch/SuperH4.S
Normal file
47
arch/SuperH4.S
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
.globl hw_bswap16
|
||||||
|
.globl hw_bswap32
|
||||||
|
.globl hw_bswap64
|
||||||
|
.globl _cu_memcpy
|
||||||
|
.globl _cu_memmove
|
||||||
|
.globl _cu_memcmp
|
||||||
|
.globl _cu_memset
|
||||||
|
.globl cu_memzero
|
||||||
|
.globl cu_memtest
|
||||||
|
.globl cu_va_start
|
||||||
|
.globl cu_va_arg
|
||||||
|
|
||||||
|
.text
|
||||||
|
.align 16
|
||||||
|
|
||||||
|
hw_bswap16:
|
||||||
|
rts
|
||||||
|
|
||||||
|
hw_bswap32:
|
||||||
|
rts
|
||||||
|
|
||||||
|
hw_bswap64:
|
||||||
|
rts
|
||||||
|
|
||||||
|
_cu_memcpy:
|
||||||
|
rts
|
||||||
|
|
||||||
|
_cu_memmove:
|
||||||
|
rts
|
||||||
|
|
||||||
|
_cu_memcmp:
|
||||||
|
rts
|
||||||
|
|
||||||
|
_cu_memset:
|
||||||
|
rts
|
||||||
|
|
||||||
|
cu_memzero:
|
||||||
|
rts
|
||||||
|
|
||||||
|
cu_memtest:
|
||||||
|
rts
|
||||||
|
|
||||||
|
cu_va_start:
|
||||||
|
rts
|
||||||
|
|
||||||
|
cu_va_arg:
|
||||||
|
rts
|
||||||
|
|
@ -21,6 +21,10 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uword fp;
|
uword fp;
|
||||||
} cu_va_list;
|
} cu_va_list;
|
||||||
|
#elif (defined(CU_ARCH_SUPERH))
|
||||||
|
typedef struct {
|
||||||
|
uword fp;
|
||||||
|
} cu_va_list;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void cu_va_start(cu_va_list* va);
|
extern void cu_va_start(cu_va_list* va);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue