From: ljsebald <ljs...@us...> - 2023-06-05 21:56:58
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 7d888dc3c4aedc0ce62289d15ebe95f5e69d87ed (commit) via 0ce9d8e12e1daefd4d7380854882403d616305fa (commit) via 4d5f3ead01edea3a22754efebac1d3a5b854a89c (commit) via 9470dd378b16477bac867940109726fa73c4731e (commit) via 842b63cfec85d7fa1c32129f5cd77e1e0138716a (commit) via 05366ccf1e92c53d6f0e7ddd0088a0149b8c0c42 (commit) via 2e7c4a72aa412dd9420fa32845437429cda38005 (commit) from 1cc2d2c6c871f55b4265169979236e0e4ab369bb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7d888dc3c4aedc0ce62289d15ebe95f5e69d87ed Merge: 1cc2d2c 0ce9d8e Author: Lawrence Sebald <ljs...@us...> Date: Mon Jun 5 17:56:28 2023 -0400 Merge pull request #240 from KallistiOS/split-patch Split GCC patching behavior into diff file and copying files from tree commit 0ce9d8e12e1daefd4d7380854882403d616305fa Author: darc <da...@pr...> Date: Mon Jun 5 11:38:30 2023 -0500 Fix patch.mk to add fetch dependency to sh4-fixup, fixing parallel building commit 4d5f3ead01edea3a22754efebac1d3a5b854a89c Author: darc <da...@pr...> Date: Mon Jun 5 10:45:41 2023 -0500 Move fake-kos/gthr-kos to patches/gcc dir commit 9470dd378b16477bac867940109726fa73c4731e Author: darc <da...@pr...> Date: Sun Jun 4 20:56:54 2023 -0500 Regenerate GCC patch files with proper formatting commit 842b63cfec85d7fa1c32129f5cd77e1e0138716a Author: darc <da...@pr...> Date: Sun Jun 4 18:56:24 2023 -0500 Fix file copy operation before patch to only run for SH4, not ARM commit 05366ccf1e92c53d6f0e7ddd0088a0149b8c0c42 Author: darc <da...@pr...> Date: Sun Jun 4 11:40:54 2023 -0500 Add notices to fake-kos, gthr-kos, and startup explaining they're part of toolchain commit 2e7c4a72aa412dd9420fa32845437429cda38005 Author: darc <da...@pr...> Date: Sun Jun 4 11:31:31 2023 -0500 Remove fake-kos, gthr-kos, and crt1 from GCC patches and copy them over from file tree instead ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/startup.s | 4 + utils/dc-chain/patches/gcc-13.1.0-kos.diff | 1481 +------------------- utils/dc-chain/patches/gcc-4.7.4-kos.diff | 2078 +--------------------------- utils/dc-chain/patches/gcc-9.3.0-kos.diff | 1475 +------------------- utils/dc-chain/patches/gcc/fake-kos.S | 82 ++ utils/dc-chain/patches/gcc/gthr-kos.h | 404 ++++++ utils/dc-chain/scripts/patch.mk | 8 + 7 files changed, 567 insertions(+), 4965 deletions(-) create mode 100644 utils/dc-chain/patches/gcc/fake-kos.S create mode 100644 utils/dc-chain/patches/gcc/gthr-kos.h diff --git a/kernel/arch/dreamcast/kernel/startup.s b/kernel/arch/dreamcast/kernel/startup.s index 5b1510d..bff92c5 100644 --- a/kernel/arch/dreamcast/kernel/startup.s +++ b/kernel/arch/dreamcast/kernel/startup.s @@ -3,6 +3,10 @@ ! startup.s ! (c)2000-2001 Megan Potter ! +! This file is added to GCC during the patching stage of toolchain +! compilation. Any changes to this file will not take effect until the +! toolchain is recompiled. +! ! This file must appear FIRST in your linking order, or your program won't ! work correctly as a raw binary. ! diff --git a/utils/dc-chain/patches/gcc-13.1.0-kos.diff b/utils/dc-chain/patches/gcc-13.1.0-kos.diff index 16667ef..0b7f0ab 100644 --- a/utils/dc-chain/patches/gcc-13.1.0-kos.diff +++ b/utils/dc-chain/patches/gcc-13.1.0-kos.diff @@ -1,6 +1,6 @@ -diff -ruN gcc-13.1.0/gcc/config/sh/sh-c.cc gcc-13.1.0-kos/gcc/config/sh/sh-c.cc ---- gcc-13.1.0/gcc/config/sh/sh-c.cc 2023-05-18 23:44:39.681991134 -0500 -+++ gcc-13.1.0-kos/gcc/config/sh/sh-c.cc 2023-05-18 23:45:23.294601687 -0500 +diff --color -ruN gcc-13.1.0/gcc/config/sh/sh-c.cc gcc-13.1.0-kos/gcc/config/sh/sh-c.cc +--- gcc-13.1.0/gcc/config/sh/sh-c.cc 2023-06-04 20:48:46.612552162 -0500 ++++ gcc-13.1.0-kos/gcc/config/sh/sh-c.cc 2023-06-04 20:49:03.486606055 -0500 @@ -141,4 +141,11 @@ cpp_define_formatted (pfile, "__SH_ATOMIC_MODEL_%s__", @@ -13,9 +13,9 @@ diff -ruN gcc-13.1.0/gcc/config/sh/sh-c.cc gcc-13.1.0-kos/gcc/config/sh/sh-c.cc + /* Toolchain supports setting up stack for 32MB */ + builtin_define ("__KOS_GCC_32MB__"); } -diff -ruN gcc-13.1.0/gcc/configure gcc-13.1.0-kos/gcc/configure ---- gcc-13.1.0/gcc/configure 2023-05-18 23:44:40.590003868 -0500 -+++ gcc-13.1.0-kos/gcc/configure 2023-05-18 23:45:23.298601742 -0500 +diff --color -ruN gcc-13.1.0/gcc/configure gcc-13.1.0-kos/gcc/configure +--- gcc-13.1.0/gcc/configure 2023-06-04 20:48:49.679561957 -0500 ++++ gcc-13.1.0-kos/gcc/configure 2023-06-04 20:49:03.488606061 -0500 @@ -13012,7 +13012,7 @@ target_thread_file='single' ;; @@ -25,1442 +25,9 @@ diff -ruN gcc-13.1.0/gcc/configure gcc-13.1.0-kos/gcc/configure target_thread_file=${enable_threads} ;; *) -diff -ruN gcc-13.1.0/libgcc/config/sh/crt1.S gcc-13.1.0-kos/libgcc/config/sh/crt1.S ---- gcc-13.1.0/libgcc/config/sh/crt1.S 2023-05-18 23:44:39.377986871 -0500 -+++ gcc-13.1.0-kos/libgcc/config/sh/crt1.S 2023-05-18 23:45:23.298601742 -0500 -@@ -1,724 +1,236 @@ --/* Copyright (C) 2000-2023 Free Software Foundation, Inc. -- This file was pretty much copied from newlib. -+! KallistiOS ##version## -+! -+! startup.s -+! (c)2000-2001 Megan Potter -+! -+! This file must appear FIRST in your linking order, or your program won't -+! work correctly as a raw binary. -+! -+! This is very loosely based on Marcus' crt0.s/startup.s -+! -+ -+.globl start -+.globl _start -+.globl _arch_real_exit -+.globl __arch_old_sr -+.globl __arch_old_vbr -+.globl __arch_old_stack -+.globl __arch_old_fpscr -+.globl __arch_mem_top - --This file is part of GCC. -+.weak _arch_stack_16m -+.weak _arch_stack_32m - --GCC is free software; you can redistribute it and/or modify it --under the terms of the GNU General Public License as published by the --Free Software Foundation; either version 3, or (at your option) any --later version. -- --GCC is distributed in the hope that it will be useful, --but WITHOUT ANY WARRANTY; without even the implied warranty of --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --General Public License for more details. -- --Under Section 7 of GPL version 3, you are granted additional --permissions described in the GCC Runtime Library Exception, version --3.1, as published by the Free Software Foundation. -- --You should have received a copy of the GNU General Public License and --a copy of the GCC Runtime Library Exception along with this program; --see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --<http://www.gnu.org/licenses/>. */ -- --#include "crt.h" -- --#ifdef MMU_SUPPORT -- /* Section used for exception/timer interrupt stack area */ -- .section .data.vbr.stack,"aw" -- .align 4 -- .global __ST_VBR --__ST_VBR: -- .zero 1024 * 2 /* ; 2k for VBR handlers */ --/* Label at the highest stack address where the stack grows from */ --__timer_stack: --#endif /* MMU_SUPPORT */ -- -- /* ;---------------------------------------- -- Normal newlib crt1.S */ -- -- ! make a place to keep any previous value of the vbr register -- ! this will only have a value if it has been set by redboot (for example) -- .section .bss --old_vbr: -- .long 0 --#ifdef PROFILE --profiling_enabled: -- .long 0 --#endif -- -- -- .section .text -- .global start -- .import ___rtos_profiler_start_timer -- .weak ___rtos_profiler_start_timer -+_start: - start: -- mov.l stack_k,r15 -- --#if defined (__SH3__) || (defined (__SH_FPU_ANY__) && ! defined (__SH2E__) && ! defined (__SH2A__)) || defined (__SH4_NOFPU__) --#define VBR_SETUP -- ! before zeroing the bss ... -- ! if the vbr is already set to vbr_start then the program has been restarted -- ! (i.e. it is not the first time the program has been run since reset) -- ! reset the vbr to its old value before old_vbr (in bss) is wiped -- ! this ensures that the later code does not create a circular vbr chain -- stc vbr, r1 -- mov.l vbr_start_k, r2 -- cmp/eq r1, r2 -- bf 0f -- ! reset the old vbr value -- mov.l old_vbr_k, r1 -- mov.l @r1, r2 -- ldc r2, vbr --0: --#endif /* VBR_SETUP */ -- -- ! zero out bss -- mov.l edata_k,r0 -- mov.l end_k,r1 -- mov #0,r2 --start_l: -- mov.l r2,@r0 -- add #4,r0 -- cmp/ge r0,r1 -- bt start_l -- --#if defined (__SH_FPU_ANY__) -- mov.l set_fpscr_k, r1 -- mov #4,r4 -- jsr @r1 -- shll16 r4 ! Set DN bit (flush denormal inputs to zero) -- lds r3,fpscr ! Switch to default precision --#endif /* defined (__SH_FPU_ANY__) */ -- --#ifdef VBR_SETUP -- ! save the existing contents of the vbr -- ! there will only be a prior value when using something like redboot -- ! otherwise it will be zero -- stc vbr, r1 -- mov.l old_vbr_k, r2 -- mov.l r1, @r2 -- ! setup vbr -- mov.l vbr_start_k, r1 -- ldc r1,vbr --#endif /* VBR_SETUP */ -- -- ! if an rtos is exporting a timer start fn, -- ! then pick up an SR which does not enable ints -- ! (the rtos will take care of this) -- mov.l rtos_start_fn, r0 -- mov.l sr_initial_bare, r1 -- tst r0, r0 -- bt set_sr -- -- mov.l sr_initial_rtos, r1 -- --set_sr: -- ! Set status register (sr) -- ldc r1, sr -- -- ! arrange for exit to call fini -- mov.l atexit_k,r0 -- mov.l fini_k,r4 -- jsr @r0 -+ ! Disable interrupts (if they're enabled) -+ mov.l old_sr_addr,r0 -+ stc sr,r1 -+ mov.l r1,@r0 -+ mov.l init_sr,r0 -+ ldc r0,sr -+ -+ ! Run in the P2 area -+ mov.l setup_cache_addr,r0 -+ mov.l p2_mask,r1 -+ or r1,r0 -+ jmp @r0 - nop - --#ifdef PROFILE -- ! arrange for exit to call _mcleanup (via stop_profiling) -- mova stop_profiling,r0 -- mov.l atexit_k,r1 -- jsr @r1 -- mov r0, r4 -- -- ! Call profiler startup code -- mov.l monstartup_k, r0 -- mov.l start_k, r4 -- mov.l etext_k, r5 -- jsr @r0 -+setup_cache: -+ ! Now that we are in P2, it's safe to enable the cache -+ ! Check to see if we should enable OCRAM. -+ mov.l kos_init_flags_addr, r0 -+ add #2, r0 -+ mov.w @r0, r0 -+ tst #1, r0 -+ bf .L_setup_cache_L0 -+ mov.w ccr_data,r1 -+ bra .L_setup_cache_L1 -+ nop -+.L_setup_cache_L0: -+ mov.w ccr_data_ocram,r1 -+.L_setup_cache_L1: -+ mov.l ccr_addr,r0 -+ mov.l r1,@r0 -+ -+ ! After changing CCR, eight instructions must be executed before -+ ! it's safe to enter a cached area such as P1 -+ nop ! 1 -+ nop ! 2 -+ nop ! 3 -+ nop ! 4 -+ nop ! 5 (d-cache now safe) -+ nop ! 6 -+ mov.l init_addr,r0 ! 7 -+ mov #0,r1 ! 8 -+ jmp @r0 ! go -+ mov r1,r0 - nop - -- ! enable profiling trap -- ! until now any trap 33s will have been ignored -- ! This means that all library functions called before this point -- ! (directly or indirectly) may have the profiling trap at the start. -- ! Therefore, only mcount itself may not have the extra header. -- mov.l profiling_enabled_k2, r0 -- mov #1, r1 -- mov.l r1, @r0 --#endif /* PROFILE */ -+init: -+ ! Save old PR on old stack so we can get to it later -+ sts.l pr,@-r15 - -- ! call init -- mov.l init_k,r0 -+ ! Save the current stack, and set a new stack (higher up in RAM) -+ mov.l old_stack_addr,r0 -+ mov.l r15,@r0 -+ mov.l new_stack_16m,r15 -+ mov.l @r15,r15 -+ -+ ! Check if 0xadffffff is a mirror of 0xacffffff, or if unique -+ ! If unique, then memory is 32MB instead of 16MB, and we must -+ ! set up new stack even higher -+ mov.l p2_mask,r0 -+ mov r0,r2 -+ or r15,r2 -+ mov #0xba,r1 -+ mov.b r1,@-r2 ! Store 0xba to 0xacffffff -+ mov.l new_stack_32m,r1 -+ mov.l @r1,r1 -+ or r0,r1 -+ mov #0xab,r0 -+ mov.b r0,@-r1 ! Store 0xab in 0xadffffff -+ mov.b @r1,r0 -+ mov.b @r2,r1 ! Reloaded values -+ cmp/eq r0,r1 ! Check if values match -+ bt memchk_done ! If so, mirror - we're done, move on -+ mov.l new_stack_32m,r15 ! If not, unique - set higher stack -+ mov.l @r15,r15 -+memchk_done: -+ mov.l mem_top_addr,r0 -+ mov.l r15,@r0 ! Save address of top of memory -+ -+ ! Save VBR -+ mov.l old_vbr_addr,r0 -+ stc vbr,r1 -+ mov.l r1,@r0 -+ -+ ! Save FPSCR -+ mov.l old_fpscr_addr,r0 -+ sts fpscr,r1 -+ mov.l r1,@r0 -+ -+ ! Reset FPSCR -+ mov #4,r4 ! Use 00040000 (DN=1) -+ mov.l fpscr_addr,r0 - jsr @r0 -- nop -+ shll16 r4 - -- ! call the mainline -- mov.l main_k,r0 -- jsr @r0 -- nop -+ ! Setup a sentinel value for frame pointer in case we're using -+ ! FRAME_POINTERS for stack tracing. -+ mov #-1,r14 - -- ! call exit -- mov r0,r4 -- mov.l exit_k,r0 -+ ! Jump to the kernel main -+ mov.l main_addr,r0 - jsr @r0 - nop -- -- .balign 4 --#ifdef PROFILE --stop_profiling: -- # stop mcount counting -- mov.l profiling_enabled_k2, r0 -- mov #0, r1 -- mov.l r1, @r0 - -- # call mcleanup -- mov.l mcleanup_k, r0 -- jmp @r0 -- nop -- -- .balign 4 --mcleanup_k: -- .long __mcleanup --monstartup_k: -- .long ___monstartup --profiling_enabled_k2: -- .long profiling_enabled --start_k: -- .long _start --etext_k: -- .long __etext --#endif /* PROFILE */ -- -- .align 2 --#if defined (__SH_FPU_ANY__) --set_fpscr_k: -- .long ___set_fpscr --#endif /* defined (__SH_FPU_ANY__) */ -- --stack_k: -- .long _stack --edata_k: -- .long _edata --end_k: -- .long _end --main_k: -- .long ___setup_argv_and_call_main --exit_k: -- .long _exit --atexit_k: -- .long _atexit --init_k: -- .long GLOBAL(_init) --fini_k: -- .long GLOBAL(_fini) --#ifdef VBR_SETUP --old_vbr_k: -- .long old_vbr --vbr_start_k: -- .long vbr_start --#endif /* VBR_SETUP */ -- --sr_initial_rtos: -- ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. -- ! Whether profiling or not, keep interrupts masked, -- ! the RTOS will enable these if required. -- .long 0x600000f1 -- --rtos_start_fn: -- .long ___rtos_profiler_start_timer -- --#ifdef PROFILE --sr_initial_bare: -- ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. -- ! For bare machine, we need to enable interrupts to get profiling working -- .long 0x60000001 --#else -- --sr_initial_bare: -- ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. -- ! Keep interrupts disabled - the application will enable as required. -- .long 0x600000f1 --#endif -- -- ! supplied for backward compatibility only, in case of linking -- ! code whose main() was compiled with an older version of GCC. -- .global ___main --___main: -- rts -- nop --#ifdef VBR_SETUP --! Exception handlers -- .section .text.vbr, "ax" --vbr_start: -- -- .org 0x100 --vbr_100: --#ifdef PROFILE -- ! Note on register usage. -- ! we use r0..r3 as scratch in this code. If we are here due to a trapa for profiling -- ! then this is OK as we are just before executing any function code. -- ! The other r4..r7 we save explicityl on the stack -- ! Remaining registers are saved by normal ABI conventions and we assert we do not -- ! use floating point registers. -- mov.l expevt_k1, r1 -- mov.l @r1, r1 -- mov.l event_mask, r0 -- and r0,r1 -- mov.l trapcode_k, r2 -- cmp/eq r1,r2 -- bt 1f -- bra handler_100 ! if not a trapa, go to default handler -- nop --1: -- mov.l trapa_k, r0 -- mov.l @r0, r0 -- shlr2 r0 ! trapa code is shifted by 2. -- cmp/eq #33, r0 -- bt 2f -- bra handler_100 -- nop --2: -- -- ! If here then it looks like we have trap #33 -- ! Now we need to call mcount with the following convention -- ! Save and restore r4..r7 -- mov.l r4,@-r15 -- mov.l r5,@-r15 -- mov.l r6,@-r15 -- mov.l r7,@-r15 -- sts.l pr,@-r15 -+ ! Program can return here (not likely) or jump here directly -+ ! from anywhere in it to go straight back to the monitor -+_arch_real_exit: -+ ! Save exit code parameter to r8 -+ mov r4, r8 -+ -+ ! Reset SR -+ mov.l old_sr,r0 -+ ldc r0,sr -+ -+ ! Disable MMU, invalidate TLB -+ mov #4,r0 -+ mov.l mmu_addr,r1 -+ mov.l r0,@r1 -+ -+ ! Wait (just in case) -+ nop ! 1 -+ nop ! 2 -+ nop ! 3 -+ nop ! 4 -+ nop ! 5 -+ nop ! 6 -+ nop ! 7 -+ nop ! 8 -+ -+ ! Restore VBR -+ mov.l old_vbr,r0 -+ ldc r0,vbr - -- ! r4 is frompc. -- ! r5 is selfpc -- ! r0 is the branch back address. -- ! The code sequence emitted by gcc for the profiling trap is -- ! .align 2 -- ! trapa #33 -- ! .align 2 -- ! .long lab Where lab is planted by the compiler. This is the address -- ! of a datum that needs to be incremented. -- sts pr, r4 ! frompc -- stc spc, r5 ! selfpc -- mov #2, r2 -- not r2, r2 ! pattern to align to 4 -- and r2, r5 ! r5 now has aligned address --! add #4, r5 ! r5 now has address of address -- mov r5, r2 ! Remember it. --! mov.l @r5, r5 ! r5 has value of lable (lab in above example) -- add #8, r2 ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |