Source: st
Version: 1.9-3.4
Followup-For: Bug #1052385
X-Debbugs-Cc: wuruil...@loongson.cn

Dear Maintainer,

The patch that supports the loongarch architecture was created with reference 
to riscv's code, and has been tested to compile successfully on loongarch.

wuruilong

-- System Information:
Debian Release: trixie/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: loong64 (loongarch64)

Kernel: Linux 5.10.0-60.96.0.126.oe2203.loongarch64 (SMP w/32 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 st (1.9-3.4) unstable; urgency=medium
 .
   * Non-maintainer upload.
   * debian/patches/02-implicit-declarations.patch: Fix an improper macro
     feature check. Thanks to Zixing Liu <zixing....@canonical.com>.
     (Closes: #1065797, #1066287, LP: #2060973)
   * debian/patches/1032955_riscv_support.patch: Add support for RISC-V
     CPU. Thanks to Steven Liu <liuq...@kuaishou.com>.
     (Closes: #1032955, LP: #2061639)
   * Switch from transitional pkg-config to pkgconf.
   * Whitespace cleanup.
Author: Andreas Beckmann <a...@debian.org>
Bug-Debian: https://bugs.debian.org/1032955
Bug-Debian: https://bugs.debian.org/1065797
Bug-Debian: https://bugs.debian.org/1066287
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2060973
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2061639

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-07-18

--- st-1.9.orig/md.S
+++ st-1.9/md.S
@@ -507,5 +507,77 @@ _st_md_cxt_restore:
 
     /****************************************************************/
 
+#elif defined(__loongarch__)
+   
+    /****************************************************************/
+    /*
+     * Internal __jmp_buf layout
+     * loongarch-asm: 
https://docs.kernel.org/translations/zh_CN/arch/loongarch/introduction.html
+     */
+    #define JB_SP  0    /* A0, SP, Stack pointer */
+    #define JB_RA  1    /* RA, Return address */
+    #define JB_FP  2    /* FP/S0 Frame pointer */
+    #define JB_S1  3    /* S1 Saved register*/
+    #define JB_S2  4    /* S2-S9,  Saved register */
+    #define JB_S3  5    /* S2-S9,  Saved register */
+    #define JB_S4  6    /* S2-S9,  Saved register */
+    #define JB_S5  7    /* S2-S9,  Saved register */
+    #define JB_S6  8    /* S2-S9,  Saved register */
+    #define JB_S7  9    /* S2-S9,  Saved register */
+    #define JB_S8  10    /* S2-S9,  Saved register */
+    #define JB_S9  11   /* S2-S9,  Saved register */
+
+
+       .file "md.S"
+       .text
+
+       /* _st_md_cxt_save(__jmp_buf env) */ 
+       .globl _st_md_cxt_save
+       .type _st_md_cxt_save, %function
+       .align 2
+    _st_md_cxt_save:
+       st.d    $sp,  $a0, JB_SP  * 8
+       st.d    $ra,  $a0, JB_RA  * 8
+       st.d    $s0,  $a0, JB_FP  * 8
+       st.d    $s1,  $a0, JB_S1  * 8
+       st.d    $s2,  $a0, JB_S2  * 8
+       st.d    $s3,  $a0, JB_S3  * 8
+       st.d    $s4,  $a0, JB_S4  * 8
+       st.d    $s5,  $a0, JB_S5  * 8
+       st.d    $s6,  $a0, JB_S6  * 8
+       st.d    $s7,  $a0, JB_S7  * 8
+       st.d    $s8,  $a0, JB_S8  * 8
+       st.d    $s9,  $a0, JB_S9  * 8
+       li.w    $a0,  0
+       jr      $ra
+       .size _st_md_cxt_save, .-_st_md_cxt_save
+
+    /****************************************************************/
+
+       /* _st_md_cxt_restore(__jmp_buf env, int val) */
+       .globl _st_md_cxt_restore
+       .type _st_md_cxt_restore, %function
+       .align 2
+    _st_md_cxt_restore:
+       ld.d        $sp,  $a0, JB_SP  * 8 
+       ld.d        $ra,  $a0, JB_RA  * 8 
+       ld.d        $s0,  $a0, JB_FP  * 8 
+       ld.d        $s1,  $a0, JB_S1  * 8 
+       ld.d        $s2,  $a0, JB_S2  * 8 
+       ld.d        $s3,  $a0, JB_S3  * 8 
+       ld.d        $s4,  $a0, JB_S4  * 8 
+       ld.d        $s5,  $a0, JB_S5  * 8 
+       ld.d        $s6,  $a0, JB_S6  * 8 
+       ld.d        $s7,  $a0, JB_S7  * 8 
+       ld.d        $s8,  $a0, JB_S8  * 8 
+       ld.d        $s9,  $a0, JB_S9  * 8 
+       li.w        $a0,  1
+       jr          $ra
+       .size _st_md_cxt_restore, .-_st_md_cxt_restore
+
+    /****************************************************************/
+
 #endif
 
--- st-1.9.orig/md.h
+++ st-1.9/md.h
@@ -447,6 +447,11 @@
 #define MD_USE_BUILTIN_SETJMP
 #define MD_GET_SP(_t) *((long *)&((_t)->context[0].__jmpbuf[0]))
 
+#elif defined(__loongarch__)
+#define MD_STACK_GROWS_DOWN
+#define MD_USE_BUILTIN_SETJMP
+#define MD_GET_SP(_t) *((long *)&((_t)->context[0].__jmpbuf[0]))
+
 #elif defined(__s390__)
 #define MD_STACK_GROWS_DOWN
 

Reply via email to