-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arc64: Add initial support of Synopsys ARCv3 targets
Synopsys ARCv3 architecture includes 32-bit ARC HS5x cores and 64-bit ARC HS6x cores. Note that libgloss for ARCv3 shares the same code base as for ARCv1/2 targets. Thus, Makefile.inc for libgloss uses sources from libgloss/arc directory except crtX.S files. Co-authored-by: Shahab Vahedi <shahab@synopsys.com> Co-authored-by: Claudiu Zissulescu <claziss@gmail.com> Co-authored-by: Bruno Mauricio <brunoasmauricio@gmail.com> Co-authored-by: Luis Silva <luis.m.silva99@hotmail.com> Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
- Loading branch information
1 parent
313ea5f
commit 37c8623
Showing
29 changed files
with
3,359 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
multilibtool_LIBRARIES += %D%/libnsim.a | ||
%C%_libnsim_a_CPPFLAGS = -I$(srcdir)/arc | ||
%C%_libnsim_a_SOURCES = \ | ||
arc/libcfunc.c \ | ||
arc/nsim-syscalls.c \ | ||
arc/sbrk.c | ||
|
||
multilibtool_LIBRARIES += %D%/libhl.a | ||
%C%_libhl_a_CFLAGS = -mvolatile-di | ||
%C%_libhl_a_CPPFLAGS = -I$(srcdir)/arc | ||
%C%_libhl_a_SOURCES = \ | ||
arc/arc-timer.c \ | ||
arc/hl-stub.c \ | ||
arc/hl-setup.c \ | ||
arc/libcfunc.c \ | ||
arc/sbrk.c \ | ||
arc/hl/hl_gw.c \ | ||
arc/hl/hl_api.c \ | ||
arc/hl/hl_open.c \ | ||
arc/hl/hl_close.c \ | ||
arc/hl/hl_read.c \ | ||
arc/hl/hl_write.c \ | ||
arc/hl/hl_lseek.c \ | ||
arc/hl/hl_unlink.c \ | ||
arc/hl/hl_isatty.c \ | ||
arc/hl/hl_clock.c \ | ||
arc/hl/hl_gettimeofday.c \ | ||
arc/hl/hl_argc.c \ | ||
arc/hl/hl_argv.c \ | ||
arc/hl/hl_exit.c | ||
|
||
multilibtool_DATA += \ | ||
%D%/crt0.o \ | ||
%D%/crtn.o \ | ||
%D%/crti.o \ | ||
arc/arc-main-helper.o \ | ||
arc/nsim.specs \ | ||
arc/hl.specs | ||
|
||
libobjs_a_SOURCES += \ | ||
%D%/crt0.S \ | ||
%D%/crtn.S \ | ||
%D%/crti.S \ | ||
arc/arc-main-helper.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
Copyright (c) 2024, Synopsys, Inc. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1) Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2) Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3) Neither the name of the Synopsys, Inc., nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef _ARC64_ASM_H | ||
#define _ARC64_ASM_H | ||
|
||
#if defined (__ARC64_ARCH32__) | ||
|
||
/* Define 32-bit word. */ | ||
.macro WORD w | ||
.word \w | ||
.endm | ||
|
||
/* Move register immediate (short): r:reg, i:immediate */ | ||
.macro MOVRI_S r, i | ||
mov_s \r, \i | ||
.endm | ||
|
||
/* Move register immediate (short): r:reg, ri:reg/immediate */ | ||
.macro MOVR_S r, ri | ||
mov_s \r, \ri | ||
.endm | ||
|
||
/* Move register immediate: r:reg, ri:reg/immediate */ | ||
.macro MOVR r, ri | ||
mov \r, \ri | ||
.endm | ||
|
||
/* Push register: r:reg */ | ||
.macro PUSHR r | ||
push \r | ||
.endm | ||
|
||
/* Pop register: r:reg */ | ||
.macro POPR r | ||
pop \r | ||
.endm | ||
|
||
/* Subtract register: r1(reg), r2(reg), r3(reg) */ | ||
.macro SUBR r1, r2, r3 | ||
sub \r1, \r2, \r3 | ||
.endm | ||
|
||
/* Add PCL-rel: r:reg, symb: symbol */ | ||
.macro ADDPCL r,symb | ||
add \r, pcl, \symb | ||
.endm | ||
|
||
#elif defined (__ARC64_ARCH64__) | ||
|
||
/* Define 64-bit word. */ | ||
.macro WORD w | ||
.xword \w | ||
.endm | ||
|
||
/* Move immediate (short): r:reg, i:immediate */ | ||
.macro MOVRI_S r, i | ||
movhl_s \r, \i | ||
orl_s \r, \r, \i | ||
.endm | ||
|
||
/* Move register immediate (short): r:reg, ri:reg/immediate */ | ||
.macro MOVR_S r, ri | ||
movl_s \r, \ri | ||
.endm | ||
|
||
/* Move register immediate: r:reg, ri:reg/immediate */ | ||
.macro MOVR r, ri | ||
movl \r, \ri | ||
.endm | ||
|
||
/* Push register: r:reg */ | ||
.macro PUSHR r | ||
pushl_s \r | ||
.endm | ||
|
||
/* Pop register: r:reg */ | ||
.macro POPR r | ||
popl_s \r | ||
.endm | ||
|
||
/* Subtract register: r1(reg), r2(reg), r3(reg) */ | ||
.macro SUBR r1, r2, r3 | ||
subl \r1, \r2, \r3 | ||
.endm | ||
|
||
/* Add PCL-rel: r:reg, symb: symbol */ | ||
.macro ADDPCL r, symb | ||
addl \r, pcl, \symb@pcl | ||
.endm | ||
|
||
#else /* !__ARC64_ARC32__ && !__ARC64_ARC64__ */ | ||
# error Please use either 32-bit or 64-bit version of arc64 compiler | ||
#endif | ||
|
||
#endif /* _ARC64_ASM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/* | ||
Copyright (c) 2024, Synopsys, Inc. All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1) Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2) Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3) Neither the name of the Synopsys, Inc., nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
/* | ||
The startup code for the ARC family of processors does the following before | ||
transferring control to user defined main label: | ||
1. Set sp to __stack_top (link time variable) | ||
2. Zero out the bss section (for uninitialized globals) | ||
After returning from main, the processor is halted and the pipeline is | ||
flushed out. | ||
*/ | ||
|
||
#include "asm.h" | ||
#include "../arc/arc-symbols.h" | ||
|
||
.macro initfp from=0, to=31 | ||
fmvi2s f0+\from,r0 | ||
.if \to-\from | ||
initfp "(\from+1)",\to | ||
.endif | ||
.endm | ||
|
||
.extern main | ||
|
||
.section .text.__startup, "ax", @progbits | ||
.global __start | ||
.type __start, @function | ||
.align 4 | ||
__start: | ||
MOVRI_S sp, STACK_TOP ; Stack address | ||
|
||
; Allow unaligned accesses. | ||
lr r2, [0xA] | ||
bset r2, r2, 19 | ||
flag r2 | ||
|
||
;;; Clear the bss segment. | ||
MOVRI_S r0, SMALL_DATA_BSS_START ; r0 = start of the bss section | ||
MOVRI_S r2, SMALL_DATA_BSS_END | ||
SUBR r2, r2, r0 ; r2 = size of the bss section in bytes | ||
MOVR_S r1, 0 ; r1 = bytes to fill in | ||
bl memset | ||
|
||
;;; Clear the registers. | ||
MOVR_S r0, 0 | ||
MOVR_S r1, 0 | ||
MOVR_S r2, 0 | ||
MOVR_S r3, 0 | ||
MOVR_S r4, 0 | ||
MOVR_S r5, 0 | ||
MOVR_S r6, 0 | ||
MOVR_S r7, 0 | ||
MOVR_S r8, 0 | ||
MOVR_S r9, 0 | ||
MOVR_S r10, 0 | ||
MOVR_S r11, 0 | ||
MOVR_S r12, 0 | ||
MOVR_S r13, 0 | ||
MOVR_S r14, 0 | ||
MOVR_S r15, 0 | ||
MOVR_S r16, 0 | ||
MOVR_S r17, 0 | ||
MOVR_S r18, 0 | ||
MOVR_S r19, 0 | ||
MOVR_S r20, 0 | ||
MOVR_S r21, 0 | ||
MOVR_S r22, 0 | ||
MOVR_S r23, 0 | ||
MOVR_S r24, 0 | ||
MOVR_S r25, 0 | ||
MOVR_S r26, 0 | ||
MOVR_S r27, 0 | ||
;; SP (r28) is initialized | ||
MOVR_S ilink, 0 | ||
MOVR r30, 0 | ||
|
||
#if defined(__ARC_FPU_DP__) || defined (__ARC_FPU_SP__) | ||
initfp 0,31 | ||
#endif | ||
|
||
;; Call constructors. | ||
jl _init | ||
|
||
;;; Setup fini routines to be called from exit | ||
MOVRI_S r0, _fini | ||
jl atexit | ||
|
||
jl __setup_argv_and_call_main | ||
|
||
j exit | ||
.size __start, .-__start | ||
|
||
;;; arc-main-helper.o object can be used to replace this function | ||
;;; and properly set up arguments and/or other low-level stuff. | ||
.section .text.__setup_argv_and_call_main,"ax",@progbits | ||
.weak __setup_argv_and_call_main | ||
.type __setup_argv_and_call_main, @function | ||
.align 4 | ||
|
||
__setup_argv_and_call_main: | ||
PUSHR blink | ||
;;; Call main() with argv[0] set to "baremetal", argv[1] to NULL and empty envp | ||
MOVR_S r0, 1 ; Set argc to 1 | ||
ADDPCL r1,.argv_data ; Set argv to the appropriate pointer | ||
MOVR_S r2, 0 | ||
MOVR_S r3, 0 | ||
|
||
MOVRI_S blink, main | ||
jl [blink] | ||
|
||
POPR blink | ||
j_s [blink] | ||
|
||
.align 4 | ||
;; Dummy program name | ||
.prog_name: | ||
.string "baremetal" | ||
;; argv data | ||
.argv_data: | ||
WORD @.prog_name | ||
WORD 0x00 | ||
.size __setup_argv_and_call_main, .-__setup_argv_and_call_main | ||
|
||
.section .text._exit_halt,"ax",@progbits | ||
.global _exit_halt | ||
.type _exit_halt, @function | ||
.align 4 | ||
_exit_halt: | ||
; r0 contains exit code | ||
mov r0, r0 | ||
flag 1 | ||
b _exit_halt | ||
.size _exit_halt, .-_exit_halt |
Oops, something went wrong.