linux/arch/cris/arch-v10/kernel/entry.S
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 *  linux/arch/cris/entry.S
   4 *
   5 *  Copyright (C) 2000, 2001, 2002 Axis Communications AB
   6 *
   7 *  Authors:    Bjorn Wesen (bjornw@axis.com)
   8 */
   9
  10/*
  11 * entry.S contains the system-call and fault low-level handling routines.
  12 *
  13 * NOTE: This code handles signal-recognition, which happens every time
  14 * after a timer-interrupt and after each system call.
  15 *
  16 * Stack layout in 'ret_from_system_call':
  17 *      ptrace needs to have all regs on the stack.
  18 *      if the order here is changed, it needs to be
  19 *      updated in fork.c:copy_process, signal.c:do_signal,
  20 *      ptrace.c and ptrace.h
  21 *
  22 */
  23
  24#include <linux/linkage.h>
  25#include <linux/sys.h>
  26#include <asm/unistd.h>
  27#include <arch/sv_addr_ag.h>
  28#include <asm/errno.h>
  29#include <asm/thread_info.h>
  30#include <asm/asm-offsets.h>
  31#include <asm/page.h>
  32#include <asm/pgtable.h>
  33
  34        ;; functions exported from this file
  35
  36        .globl system_call
  37        .globl ret_from_intr
  38        .globl ret_from_fork
  39        .globl ret_from_kernel_thread
  40        .globl resume
  41        .globl multiple_interrupt
  42        .globl hwbreakpoint
  43        .globl IRQ1_interrupt
  44        .globl spurious_interrupt
  45        .globl hw_bp_trigs
  46        .globl mmu_bus_fault
  47        .globl do_sigtrap
  48        .globl gdb_handle_breakpoint
  49        .globl sys_call_table
  50
  51        ;; below are various parts of system_call which are not in the fast-path
  52
  53#ifdef CONFIG_PREEMPT
  54        ; Check if preemptive kernel scheduling should be done
  55_resume_kernel:
  56        di
  57        ; Load current task struct
  58        movs.w  -8192, $r0      ;  THREAD_SIZE = 8192
  59        and.d   $sp, $r0
  60        move.d  [$r0+TI_preempt_count], $r10    ;  Preemption disabled?
  61        bne     _Rexit
  62        nop
  63_need_resched:
  64        move.d  [$r0+TI_flags], $r10
  65        btstq   TIF_NEED_RESCHED, $r10  ; Check if need_resched is set
  66        bpl     _Rexit
  67        nop
  68        ; Ok, lets's do some preemptive kernel scheduling
  69        jsr     preempt_schedule_irq
  70        ; Load new task struct
  71        movs.w  -8192, $r0      ;  THREAD_SIZE = 8192
  72        and.d   $sp, $r0
  73        ; One more time (with new task)
  74        ba      _need_resched
  75        nop
  76#else
  77#define _resume_kernel _Rexit
  78#endif
  79
  80        ; Called at exit from fork. schedule_tail must be called to drop
  81        ; spinlock if CONFIG_PREEMPT
  82ret_from_fork:
  83        jsr schedule_tail
  84        ba  ret_from_sys_call
  85        nop
  86
  87ret_from_kernel_thread:
  88        jsr schedule_tail
  89        move.d  $r2, $r10       ; argument is here
  90        jsr     $r1             ; call the payload
  91        moveq   0, $r9          ; no syscall restarts, TYVM...
  92        ba  ret_from_sys_call
  93
  94ret_from_intr:
  95        ;; check for resched if preemptive kernel or if we're going back to user-mode
  96        ;; this test matches the user_regs(regs) macro
  97        ;; we cannot simply test $dccr, because that does not necessarily
  98        ;; reflect what mode we'll return into.
  99
 100        move.d  [$sp + PT_dccr], $r0; regs->dccr
 101        btstq   8, $r0          ; U-flag
 102        bpl     _resume_kernel
 103        ; Note that di below is in delay slot
 104
 105_resume_userspace:
 106        di                      ; so need_resched and sigpending don't change
 107
 108        movs.w  -8192, $r0      ; THREAD_SIZE == 8192
 109        and.d   $sp, $r0
 110
 111        move.d  [$r0+TI_flags], $r10    ; current->work
 112        and.d   _TIF_WORK_MASK, $r10    ; is there any work to be done on return
 113        bne     _work_pending
 114        nop
 115        ba      _Rexit
 116        nop
 117
 118        ;; The system_call is called by a BREAK instruction, which works like
 119        ;; an interrupt call but it stores the return PC in BRP instead of IRP.
 120        ;; Since we dont really want to have two epilogues (one for system calls
 121        ;; and one for interrupts) we push the contents of BRP instead of IRP in the
 122        ;; system call prologue, to make it look like an ordinary interrupt on the
 123        ;; stackframe.
 124        ;;
 125        ;; Since we can't have system calls inside interrupts, it should not matter
 126        ;; that we don't stack IRP.
 127        ;;
 128        ;; In r9 we have the wanted syscall number. Arguments come in r10,r11,r12,r13,mof,srp
 129        ;;
 130        ;; This function looks on the _surface_ like spaghetti programming, but it's
 131        ;; really designed so that the fast-path does not force cache-loading of non-used
 132        ;; instructions. Only the non-common cases cause the outlined code to run..
 133
 134system_call:
 135        ;; stack-frame similar to the irq heads, which is reversed in ret_from_sys_call
 136        move    $brp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame
 137        push    $srp
 138        push    $dccr
 139        push    $mof
 140        subq    14*4, $sp               ; make room for r0-r13
 141        movem   $r13, [$sp]     ; push r0-r13
 142        push    $r10            ; push orig_r10
 143        clear.d [$sp=$sp-4]     ; frametype == 0, normal stackframe
 144
 145        movs.w  -ENOSYS, $r0
 146        move.d  $r0, [$sp+PT_r10]       ; put the default return value in r10 in the frame
 147
 148        ;; check if this process is syscall-traced
 149
 150        movs.w  -8192, $r0      ; THREAD_SIZE == 8192
 151        and.d   $sp, $r0
 152
 153        move.d  [$r0+TI_flags], $r0
 154        btstq   TIF_SYSCALL_TRACE, $r0
 155        bmi     _syscall_trace_entry
 156        nop
 157
 158_syscall_traced:
 159
 160        ;; check for sanity in the requested syscall number
 161
 162        cmpu.w  NR_syscalls, $r9
 163        bcc     ret_from_sys_call
 164        lslq    2, $r9          ;  multiply by 4, in the delay slot
 165
 166        ;; as a bonus 7th parameter, we give the location on the stack
 167        ;; of the register structure itself. some syscalls need this.
 168
 169        push    $sp
 170
 171        ;; the parameter carrying registers r10, r11, r12 and 13 are intact.
 172        ;; the fifth and sixth parameters (if any) was in mof and srp
 173        ;; respectively, and we need to put them on the stack.
 174
 175        push    $srp
 176        push    $mof
 177
 178        jsr     [$r9+sys_call_table]    ; actually do the system call
 179        addq    3*4, $sp                ; pop the mof, srp and regs parameters
 180        move.d  $r10, [$sp+PT_r10]      ; save the return value
 181
 182        moveq   1, $r9          ; "parameter" to ret_from_sys_call to show it was a sys call
 183
 184        ;; fall through into ret_from_sys_call to return
 185
 186ret_from_sys_call:
 187        ;; r9 is a parameter - if >=1 we came from a syscall, if 0, from an irq
 188
 189        ;; get the current task-struct pointer (see top for defs)
 190
 191        movs.w  -8192, $r0      ; THREAD_SIZE == 8192
 192        and.d   $sp, $r0
 193
 194        di                      ; make sure need_resched and sigpending don't change
 195        move.d  [$r0+TI_flags],$r1
 196        and.d   _TIF_ALLWORK_MASK, $r1
 197        bne     _syscall_exit_work
 198        nop
 199
 200_Rexit:
 201        ;; this epilogue MUST match the prologues in multiple_interrupt, irq.h and ptregs.h
 202        pop     $r10            ; frametype
 203        bne     _RBFexit        ; was not CRIS_FRAME_NORMAL, handle otherwise
 204        addq    4, $sp          ; skip orig_r10, in delayslot
 205        movem   [$sp+], $r13    ; registers r0-r13
 206        pop     $mof            ; multiply overflow register
 207        pop     $dccr           ; condition codes
 208        pop     $srp            ; subroutine return pointer
 209        ;; now we have a 4-word SBFS frame which we do not want to restore
 210        ;; using RBF since it was not stacked with SBFS. instead we would like to
 211        ;; just get the PC value to restart it with, and skip the rest of
 212        ;; the frame.
 213        ;; Also notice that it's important to use instructions here that
 214        ;; keep the interrupts disabled (since we've already popped DCCR)
 215        move    [$sp=$sp+16], $p8; pop the SBFS frame from the sp
 216        jmpu    [$sp-16]        ; return through the irp field in the sbfs frame
 217
 218_RBFexit:
 219        movem   [$sp+], $r13    ; registers r0-r13, in delay slot
 220        pop     $mof            ; multiply overflow register
 221        pop     $dccr           ; condition codes
 222        pop     $srp            ; subroutine return pointer
 223        rbf     [$sp+]          ; return by popping the CPU status
 224
 225        ;; We get here after doing a syscall if extra work might need to be done
 226        ;; perform syscall exit tracing if needed
 227
 228_syscall_exit_work:
 229        ;; $r0 contains current at this point and irq's are disabled
 230
 231        move.d  [$r0+TI_flags], $r1
 232        btstq   TIF_SYSCALL_TRACE, $r1
 233        bpl     _work_pending
 234        nop
 235
 236        ei
 237
 238        move.d  $r9, $r1        ; preserve r9
 239        jsr     do_syscall_trace
 240        move.d  $r1, $r9
 241
 242        ba      _resume_userspace
 243        nop
 244
 245_work_pending:
 246        move.d  [$r0+TI_flags], $r1
 247        btstq   TIF_NEED_RESCHED, $r1
 248        bpl     _work_notifysig ; was neither trace nor sched, must be signal/notify
 249        nop
 250
 251_work_resched:
 252        move.d  $r9, $r1        ; preserve r9
 253        jsr     schedule
 254        move.d  $r1, $r9
 255        di
 256
 257        move.d  [$r0+TI_flags], $r1
 258        and.d   _TIF_WORK_MASK, $r1; ignore the syscall trace counter
 259        beq     _Rexit
 260        nop
 261        btstq   TIF_NEED_RESCHED, $r1
 262        bmi     _work_resched   ; current->work.need_resched
 263        nop
 264
 265_work_notifysig:
 266        ;; deal with pending signals and notify-resume requests
 267
 268        move.d  $r9, $r10       ; do_notify_resume syscall/irq param
 269        move.d  $sp, $r11       ; the regs param
 270        move.d  $r1, $r12       ; the thread_info_flags parameter
 271        jsr     do_notify_resume
 272
 273        ba _Rexit
 274        nop
 275
 276        ;; We get here as a sidetrack when we've entered a syscall with the
 277        ;; trace-bit set. We need to call do_syscall_trace and then continue
 278        ;; with the call.
 279
 280_syscall_trace_entry:
 281        ;; PT_r10 in the frame contains -ENOSYS as required, at this point
 282
 283        jsr     do_syscall_trace
 284
 285        ;; now re-enter the syscall code to do the syscall itself
 286        ;; we need to restore $r9 here to contain the wanted syscall, and
 287        ;; the other parameter-bearing registers
 288
 289        move.d  [$sp+PT_r9], $r9
 290        move.d  [$sp+PT_orig_r10], $r10  ; PT_r10 is already filled with -ENOSYS.
 291        move.d  [$sp+PT_r11],      $r11
 292        move.d  [$sp+PT_r12],      $r12
 293        move.d  [$sp+PT_r13],      $r13
 294        move    [$sp+PT_mof],      $mof
 295        move    [$sp+PT_srp],      $srp
 296
 297        ba      _syscall_traced
 298        nop
 299
 300        ;; resume performs the actual task-switching, by switching stack pointers
 301        ;; input arguments: r10 = prev, r11 = next, r12 = thread offset in task struct
 302        ;; returns old current in r10
 303        ;;
 304        ;; TODO:  see the i386 version. The switch_to which calls resume in our version
 305        ;;        could really be an inline asm of this.
 306
 307resume:
 308        push    $srp                     ; we keep the old/new PC on the stack
 309        add.d   $r12, $r10               ; r10 = current tasks tss
 310        move    $dccr, [$r10+THREAD_dccr]; save irq enable state
 311        di
 312
 313        move    $usp, [$r10+ THREAD_usp] ; save user-mode stackpointer
 314
 315        ;; See copy_thread for the reason why register R9 is saved.
 316        subq    10*4, $sp
 317        movem   $r9, [$sp]               ; save non-scratch registers and R9.
 318
 319        move.d  $sp, [$r10+THREAD_ksp]   ; save the kernel stack pointer for the old task
 320        move.d  $sp, $r10                ; return last running task in r10
 321        and.d   -8192, $r10              ; get thread_info from stackpointer
 322        move.d  [$r10+TI_task], $r10     ; get task
 323        add.d   $r12, $r11               ; find the new tasks tss
 324        move.d  [$r11+THREAD_ksp], $sp   ; switch into the new stackframe by restoring kernel sp
 325
 326        movem   [$sp+], $r9              ; restore non-scratch registers and R9.
 327
 328        move    [$r11+THREAD_usp], $usp ; restore user-mode stackpointer
 329
 330        move    [$r11+THREAD_dccr], $dccr ; restore irq enable status
 331        jump    [$sp+]                   ; restore PC
 332
 333        ;; This is the MMU bus fault handler.
 334        ;; It needs to stack the CPU status and overall is different
 335        ;; from the other interrupt handlers.
 336
 337mmu_bus_fault:
 338        ;; For refills we try to do a quick page table lookup. If it is
 339        ;; a real fault we let the mm subsystem handle it.
 340
 341        ;; the first longword in the sbfs frame was the interrupted PC
 342        ;; which fits nicely with the "IRP" slot in pt_regs normally used to
 343        ;; contain the return address. used by Oops to print kernel errors.
 344        sbfs    [$sp=$sp-16]    ; push the internal CPU status
 345        push    $dccr
 346        di
 347        subq    2*4, $sp
 348        movem   $r1, [$sp]
 349        move.d  [R_MMU_CAUSE], $r1
 350        ;; ETRAX 100LX TR89 bugfix: if the second half of an unaligned
 351        ;; write causes a MMU-fault, it will not be restarted correctly.
 352        ;; This could happen if a write crosses a page-boundary and the
 353        ;; second page is not yet COW'ed or even loaded. The workaround
 354        ;; is to clear the unaligned bit in the CPU status record, so
 355        ;; that the CPU will rerun both the first and second halves of
 356        ;; the instruction. This will not have any sideeffects unless
 357        ;; the first half goes to any device or memory that can't be
 358        ;; written twice, and which is mapped through the MMU.
 359        ;;
 360        ;; We only need to do this for writes.
 361        btstq   8, $r1             ; Write access?
 362        bpl     1f
 363        nop
 364        move.d  [$sp+16], $r0      ; Clear unaligned bit in csrinstr
 365        and.d   ~(1<<5), $r0
 366        move.d  $r0, [$sp+16]
 3671:      btstq   12, $r1            ; Refill?
 368        bpl     2f
 369        lsrq    24, $r1     ; Get PGD index (bit 24-31)
 370        move.d  [current_pgd], $r0 ; PGD for the current process
 371        move.d  [$r0+$r1.d], $r0   ; Get PMD
 372        beq     2f
 373        nop
 374        and.w   PAGE_MASK, $r0     ; Remove PMD flags
 375        move.d  [R_MMU_CAUSE], $r1
 376        lsrq    PAGE_SHIFT, $r1
 377        and.d   0x7ff, $r1         ; Get PTE index into PGD (bit 13-23)
 378        move.d  [$r0+$r1.d], $r1   ; Get PTE
 379        beq     2f
 380        nop
 381        ;; Store in TLB
 382        move.d  $r1, [R_TLB_LO]
 383        ;; Return
 384        movem   [$sp+], $r1
 385        pop     $dccr
 386        rbf     [$sp+]          ; return by popping the CPU status
 387
 3882:      ; PMD or PTE missing, let the mm subsystem fix it up.
 389        movem   [$sp+], $r1
 390        pop     $dccr
 391
 392        ; Ok, not that easy, pass it on to the mm subsystem
 393        ; The MMU status record is now on the stack
 394        push    $srp            ; make a stackframe similar to pt_regs
 395        push    $dccr
 396        push    $mof
 397        di
 398        subq    14*4, $sp
 399        movem   $r13, [$sp]
 400        push    $r10            ; dummy orig_r10
 401        moveq   1, $r10
 402        push    $r10            ; frametype == 1, BUSFAULT frame type
 403
 404        move.d  $sp, $r10       ; pt_regs argument to handle_mmu_bus_fault
 405
 406        jsr     handle_mmu_bus_fault  ; in arch/cris/arch-v10/mm/fault.c
 407
 408        ;; now we need to return through the normal path, we cannot just
 409        ;; do the RBFexit since we might have killed off the running
 410        ;; process due to a SEGV, scheduled due to a page blocking or
 411        ;; whatever.
 412
 413        moveq   0, $r9          ; busfault is equivalent to an irq
 414
 415        ba      ret_from_intr
 416        nop
 417
 418        ;; special handlers for breakpoint and NMI
 419hwbreakpoint:
 420        push    $dccr
 421        di
 422        push    $r10
 423        push    $r11
 424        move.d  [hw_bp_trig_ptr],$r10
 425        move    $brp,$r11
 426        move.d  $r11,[$r10+]
 427        move.d  $r10,[hw_bp_trig_ptr]
 4281:      pop     $r11
 429        pop     $r10
 430        pop     $dccr
 431        retb
 432        nop
 433
 434IRQ1_interrupt:
 435        ;; this prologue MUST match the one in irq.h and the struct in ptregs.h!!!
 436        move    $brp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame
 437        push    $srp
 438        push    $dccr
 439        push    $mof
 440        di
 441        subq    14*4, $sp
 442        movem   $r13, [$sp]
 443        push    $r10            ; push orig_r10
 444        clear.d [$sp=$sp-4]     ; frametype == 0, normal frame
 445
 446        ;; If there is a glitch on the NMI pin shorter than ~100ns
 447        ;; (i.e. non-active by the time we get here) then the nmi_pin bit
 448        ;; in R_IRQ_MASK0_RD will already be cleared.  The watchdog_nmi bit
 449        ;; is cleared by us however (when feeding the watchdog), which is why
 450        ;; we use that bit to determine what brought us here.
 451
 452        move.d  [R_IRQ_MASK0_RD], $r1 ; External NMI or watchdog?
 453        and.d   (1<<30), $r1
 454        bne     wdog
 455        move.d  $sp, $r10
 456        jsr     handle_nmi
 457        setf m                  ; Enable NMI again
 458        ba      _Rexit          ; Return the standard way
 459        nop
 460wdog:
 461#if defined(CONFIG_ETRAX_WATCHDOG)
 462;; Check if we're waiting for reset to happen, as signalled by
 463;; hard_reset_now setting cause_of_death to a magic value.  If so, just
 464;; get stuck until reset happens.
 465        .comm   cause_of_death, 4       ;; Don't declare this anywhere.
 466        move.d  [cause_of_death], $r10
 467        cmp.d   0xbedead, $r10
 468_killed_by_death:
 469        beq     _killed_by_death
 470        nop
 471
 472;; We'll see this in ksymoops dumps.
 473Watchdog_bite:
 474
 475#ifdef CONFIG_ETRAX_WATCHDOG_NICE_DOGGY
 476       ;; We just restart the watchdog here to be sure we dont get
 477       ;; hit while printing the watchdogmsg below
 478       ;; This restart is compatible with the rest of the C-code, so
 479       ;; the C-code can keep restarting the watchdog after this point.
 480       ;; The non-NICE_DOGGY code below though, disables the possibility
 481       ;; to restart since it changes the watchdog key, to avoid any
 482       ;; buggy loops etc. keeping the watchdog alive after this.
 483       jsr     reset_watchdog
 484#else
 485
 486;; We need to extend the 3.3ms after the NMI at watchdog bite, so we have
 487;; time for an oops-dump over a 115k2 serial wire.  Another 100ms should do.
 488
 489;; Change the watchdog key to an arbitrary 3-bit value and restart the
 490;; watchdog.
 491#define WD_INIT 2
 492        moveq     IO_FIELD (R_WATCHDOG, key, WD_INIT), $r10
 493        move.d  R_WATCHDOG, $r11
 494
 495        move.d  $r10, [$r11]
 496        moveq     IO_FIELD (R_WATCHDOG, key,                            \
 497                            IO_EXTRACT (R_WATCHDOG, key,                \
 498                                        IO_MASK (R_WATCHDOG, key))      \
 499                            ^ WD_INIT)                                  \
 500                | IO_STATE (R_WATCHDOG, enable, start), $r10
 501        move.d  $r10, [$r11]
 502
 503#endif
 504
 505;; Note that we don't do "setf m" here (or after two necessary NOPs),
 506;; since *not* doing that saves us from re-entrancy checks.  We don't want
 507;; to get here again due to possible subsequent NMIs; we want the watchdog
 508;; to reset us.
 509
 510        move.d  _watchdogmsg,$r10
 511        jsr     printk
 512
 513        move.d  $sp, $r10
 514        jsr     watchdog_bite_hook
 515
 516;; This nop is here so we see the "Watchdog_bite" label in ksymoops dumps
 517;; rather than "spurious_interrupt".
 518        nop
 519;; At this point we drop down into spurious_interrupt, which will do a
 520;; hard reset.
 521
 522        .section .rodata,"a"
 523_watchdogmsg:
 524        .ascii  "Oops: bitten by watchdog\n\0"
 525        .previous
 526
 527#endif /* CONFIG_ETRAX_WATCHDOG */
 528
 529spurious_interrupt:
 530        di
 531        jump hard_reset_now
 532
 533        ;; this handles the case when multiple interrupts arrive at the same time
 534        ;; we jump to the first set interrupt bit in a priority fashion
 535        ;; the hardware will call the unserved interrupts after the handler finishes
 536
 537multiple_interrupt:
 538        ;; this prologue MUST match the one in irq.h and the struct in ptregs.h!!!
 539        move    $irp,[$sp=$sp-16]; instruction pointer and room for a fake SBFS frame
 540        push    $srp
 541        push    $dccr
 542        push    $mof
 543        di
 544        subq    14*4, $sp
 545        movem   $r13, [$sp]
 546        push    $r10            ; push orig_r10
 547        clear.d [$sp=$sp-4]     ; frametype == 0, normal frame
 548
 549        move.d  $sp, $r10
 550        jsr     do_multiple_IRQ
 551
 552        jump    ret_from_intr
 553
 554do_sigtrap:
 555        ;;
 556        ;; SIGTRAP the process that executed the break instruction.
 557        ;; Make a frame that Rexit in entry.S expects.
 558        ;;
 559        move    $brp, [$sp=$sp-16]      ; Push BRP while faking a cpu status record.
 560        push    $srp                    ; Push subroutine return pointer.
 561        push    $dccr                   ; Push condition codes.
 562        push    $mof                    ; Push multiply overflow reg.
 563        di                              ; Need to disable irq's at this point.
 564        subq    14*4, $sp               ; Make room for r0-r13.
 565        movem   $r13, [$sp]             ; Push the r0-r13 registers.
 566        push    $r10                    ; Push orig_r10.
 567        clear.d [$sp=$sp-4]             ; Frametype - this is a normal stackframe.
 568
 569        movs.w  -8192,$r9               ; THREAD_SIZE == 8192
 570        and.d   $sp, $r9
 571        move.d  [$r9+TI_task], $r10
 572        move.d  [$r10+TASK_pid], $r10   ; current->pid as arg1.
 573        moveq   5, $r11                 ; SIGTRAP as arg2.
 574        jsr     sys_kill
 575        jump    ret_from_intr           ; Use the return routine for interrupts.
 576
 577gdb_handle_breakpoint:
 578        push    $dccr
 579        push    $r0
 580#ifdef CONFIG_ETRAX_KGDB
 581        move    $dccr, $r0              ; U-flag not affected by previous insns.
 582        btstq   8, $r0                  ; Test the U-flag.
 583        bmi     _ugdb_handle_breakpoint ; Go to user mode debugging.
 584        nop                             ; Empty delay slot (cannot pop r0 here).
 585        pop     $r0                     ; Restore r0.
 586        ba      kgdb_handle_breakpoint  ; Go to kernel debugging.
 587        pop     $dccr                   ; Restore dccr in delay slot.
 588#endif
 589
 590_ugdb_handle_breakpoint:
 591        move    $brp, $r0               ; Use r0 temporarily for calculation.
 592        subq    2, $r0                  ; Set to address of previous instruction.
 593        move    $r0, $brp
 594        pop     $r0                     ; Restore r0.
 595        ba      do_sigtrap              ; SIGTRAP the offending process.
 596        pop     $dccr                   ; Restore dccr in delay slot.
 597
 598        .data
 599
 600hw_bp_trigs:
 601        .space 64*4
 602hw_bp_trig_ptr:
 603        .dword hw_bp_trigs
 604
 605        .section .rodata,"a"
 606sys_call_table:
 607        .long sys_restart_syscall       /* 0 - old "setup()" system call, used for restarting */
 608        .long sys_exit
 609        .long sys_fork
 610        .long sys_read
 611        .long sys_write
 612        .long sys_open          /* 5 */
 613        .long sys_close
 614        .long sys_waitpid
 615        .long sys_creat
 616        .long sys_link
 617        .long sys_unlink        /* 10 */
 618        .long sys_execve
 619        .long sys_chdir
 620        .long sys_time
 621        .long sys_mknod
 622        .long sys_chmod         /* 15 */
 623        .long sys_lchown16
 624        .long sys_ni_syscall    /* old break syscall holder */
 625        .long sys_stat
 626        .long sys_lseek
 627        .long sys_getpid        /* 20 */
 628        .long sys_mount
 629        .long sys_oldumount
 630        .long sys_setuid16
 631        .long sys_getuid16
 632        .long sys_stime         /* 25 */
 633        .long sys_ptrace
 634        .long sys_alarm
 635        .long sys_fstat
 636        .long sys_pause
 637        .long sys_utime         /* 30 */
 638        .long sys_ni_syscall    /* old stty syscall holder */
 639        .long sys_ni_syscall    /* old gtty syscall holder */
 640        .long sys_access
 641        .long sys_nice
 642        .long sys_ni_syscall    /* 35  old ftime syscall holder */
 643        .long sys_sync
 644        .long sys_kill
 645        .long sys_rename
 646        .long sys_mkdir
 647        .long sys_rmdir         /* 40 */
 648        .long sys_dup
 649        .long sys_pipe
 650        .long sys_times
 651        .long sys_ni_syscall    /* old prof syscall holder */
 652        .long sys_brk           /* 45 */
 653        .long sys_setgid16
 654        .long sys_getgid16
 655        .long sys_signal
 656        .long sys_geteuid16
 657        .long sys_getegid16     /* 50 */
 658        .long sys_acct
 659        .long sys_umount        /* recycled never used phys( */
 660        .long sys_ni_syscall    /* old lock syscall holder */
 661        .long sys_ioctl
 662        .long sys_fcntl         /* 55 */
 663        .long sys_ni_syscall    /* old mpx syscall holder */
 664        .long sys_setpgid
 665        .long sys_ni_syscall    /* old ulimit syscall holder */
 666        .long sys_ni_syscall    /* old sys_olduname holder */
 667        .long sys_umask         /* 60 */
 668        .long sys_chroot
 669        .long sys_ustat
 670        .long sys_dup2
 671        .long sys_getppid
 672        .long sys_getpgrp       /* 65 */
 673        .long sys_setsid
 674        .long sys_sigaction
 675        .long sys_sgetmask
 676        .long sys_ssetmask
 677        .long sys_setreuid16    /* 70 */
 678        .long sys_setregid16
 679        .long sys_sigsuspend
 680        .long sys_sigpending
 681        .long sys_sethostname
 682        .long sys_setrlimit     /* 75 */
 683        .long sys_old_getrlimit
 684        .long sys_getrusage
 685        .long sys_gettimeofday
 686        .long sys_settimeofday
 687        .long sys_getgroups16   /* 80 */
 688        .long sys_setgroups16
 689        .long sys_select        /* was old_select in Linux/E100 */
 690        .long sys_symlink
 691        .long sys_lstat
 692        .long sys_readlink      /* 85 */
 693        .long sys_uselib
 694        .long sys_swapon
 695        .long sys_reboot
 696        .long sys_old_readdir
 697        .long sys_old_mmap      /* 90 */
 698        .long sys_munmap
 699        .long sys_truncate
 700        .long sys_ftruncate
 701        .long sys_fchmod
 702        .long sys_fchown16      /* 95 */
 703        .long sys_getpriority
 704        .long sys_setpriority
 705        .long sys_ni_syscall    /* old profil syscall holder */
 706        .long sys_statfs
 707        .long sys_fstatfs       /* 100 */
 708        .long sys_ni_syscall    /* sys_ioperm in i386 */
 709        .long sys_socketcall
 710        .long sys_syslog
 711        .long sys_setitimer
 712        .long sys_getitimer     /* 105 */
 713        .long sys_newstat
 714        .long sys_newlstat
 715        .long sys_newfstat
 716        .long sys_ni_syscall    /* old sys_uname holder */
 717        .long sys_ni_syscall    /* 110 */ /* sys_iopl in i386 */
 718        .long sys_vhangup
 719        .long sys_ni_syscall    /* old "idle" system call */
 720        .long sys_ni_syscall    /* vm86old in i386 */
 721        .long sys_wait4
 722        .long sys_swapoff       /* 115 */
 723        .long sys_sysinfo
 724        .long sys_ipc
 725        .long sys_fsync
 726        .long sys_sigreturn
 727        .long sys_clone         /* 120 */
 728        .long sys_setdomainname
 729        .long sys_newuname
 730        .long sys_ni_syscall    /* sys_modify_ldt */
 731        .long sys_adjtimex
 732        .long sys_mprotect      /* 125 */
 733        .long sys_sigprocmask
 734        .long sys_ni_syscall    /* old "create_module" */
 735        .long sys_init_module
 736        .long sys_delete_module
 737        .long sys_ni_syscall    /* 130: old "get_kernel_syms" */
 738        .long sys_quotactl
 739        .long sys_getpgid
 740        .long sys_fchdir
 741        .long sys_bdflush
 742        .long sys_sysfs         /* 135 */
 743        .long sys_personality
 744        .long sys_ni_syscall    /* for afs_syscall */
 745        .long sys_setfsuid16
 746        .long sys_setfsgid16
 747        .long sys_llseek        /* 140 */
 748        .long sys_getdents
 749        .long sys_select
 750        .long sys_flock
 751        .long sys_msync
 752        .long sys_readv         /* 145 */
 753        .long sys_writev
 754        .long sys_getsid
 755        .long sys_fdatasync
 756        .long sys_sysctl
 757        .long sys_mlock         /* 150 */
 758        .long sys_munlock
 759        .long sys_mlockall
 760        .long sys_munlockall
 761        .long sys_sched_setparam
 762        .long sys_sched_getparam        /* 155 */
 763        .long sys_sched_setscheduler
 764        .long sys_sched_getscheduler
 765        .long sys_sched_yield
 766        .long sys_sched_get_priority_max
 767        .long sys_sched_get_priority_min        /* 160 */
 768        .long sys_sched_rr_get_interval
 769        .long sys_nanosleep
 770        .long sys_mremap
 771        .long sys_setresuid16
 772        .long sys_getresuid16   /* 165 */
 773        .long sys_ni_syscall    /* sys_vm86 */
 774        .long sys_ni_syscall    /* Old sys_query_module */
 775        .long sys_poll
 776        .long sys_ni_syscall    /* old nfsservctl */
 777        .long sys_setresgid16   /* 170 */
 778        .long sys_getresgid16
 779        .long sys_prctl
 780        .long sys_rt_sigreturn
 781        .long sys_rt_sigaction
 782        .long sys_rt_sigprocmask        /* 175 */
 783        .long sys_rt_sigpending
 784        .long sys_rt_sigtimedwait
 785        .long sys_rt_sigqueueinfo
 786        .long sys_rt_sigsuspend
 787        .long sys_pread64       /* 180 */
 788        .long sys_pwrite64
 789        .long sys_chown16
 790        .long sys_getcwd
 791        .long sys_capget
 792        .long sys_capset        /* 185 */
 793        .long sys_sigaltstack
 794        .long sys_sendfile
 795        .long sys_ni_syscall    /* streams1 */
 796        .long sys_ni_syscall    /* streams2 */
 797        .long sys_vfork         /* 190 */
 798        .long sys_getrlimit
 799        .long sys_mmap2         /* mmap_pgoff */
 800        .long sys_truncate64
 801        .long sys_ftruncate64
 802        .long sys_stat64        /* 195 */
 803        .long sys_lstat64
 804        .long sys_fstat64
 805        .long sys_lchown
 806        .long sys_getuid
 807        .long sys_getgid        /* 200 */
 808        .long sys_geteuid
 809        .long sys_getegid
 810        .long sys_setreuid
 811        .long sys_setregid
 812        .long sys_getgroups     /* 205 */
 813        .long sys_setgroups
 814        .long sys_fchown
 815        .long sys_setresuid
 816        .long sys_getresuid
 817        .long sys_setresgid     /* 210 */
 818        .long sys_getresgid
 819        .long sys_chown
 820        .long sys_setuid
 821        .long sys_setgid
 822        .long sys_setfsuid      /* 215 */
 823        .long sys_setfsgid
 824        .long sys_pivot_root
 825        .long sys_mincore
 826        .long sys_madvise
 827        .long sys_getdents64    /* 220 */
 828        .long sys_fcntl64
 829        .long sys_ni_syscall    /* reserved for TUX */
 830        .long sys_ni_syscall
 831        .long sys_gettid
 832        .long sys_readahead     /* 225 */
 833        .long sys_setxattr
 834        .long sys_lsetxattr
 835        .long sys_fsetxattr
 836        .long sys_getxattr
 837        .long sys_lgetxattr     /* 230 */
 838        .long sys_fgetxattr
 839        .long sys_listxattr
 840        .long sys_llistxattr
 841        .long sys_flistxattr
 842        .long sys_removexattr   /* 235 */
 843        .long sys_lremovexattr
 844        .long sys_fremovexattr
 845        .long sys_tkill
 846        .long sys_sendfile64
 847        .long sys_futex         /* 240 */
 848        .long sys_sched_setaffinity
 849        .long sys_sched_getaffinity
 850        .long sys_ni_syscall    /* sys_set_thread_area */
 851        .long sys_ni_syscall    /* sys_get_thread_area */
 852        .long sys_io_setup      /* 245 */
 853        .long sys_io_destroy
 854        .long sys_io_getevents
 855        .long sys_io_submit
 856        .long sys_io_cancel
 857        .long sys_fadvise64     /* 250 */
 858        .long sys_ni_syscall
 859        .long sys_exit_group
 860        .long sys_lookup_dcookie
 861        .long sys_epoll_create
 862        .long sys_epoll_ctl     /* 255 */
 863        .long sys_epoll_wait
 864        .long sys_remap_file_pages
 865        .long sys_set_tid_address
 866        .long sys_timer_create
 867        .long sys_timer_settime         /* 260 */
 868        .long sys_timer_gettime
 869        .long sys_timer_getoverrun
 870        .long sys_timer_delete
 871        .long sys_clock_settime
 872        .long sys_clock_gettime         /* 265 */
 873        .long sys_clock_getres
 874        .long sys_clock_nanosleep
 875        .long sys_statfs64
 876        .long sys_fstatfs64
 877        .long sys_tgkill                /* 270 */
 878        .long sys_utimes
 879        .long sys_fadvise64_64
 880        .long sys_ni_syscall    /* sys_vserver */
 881        .long sys_ni_syscall    /* sys_mbind */
 882        .long sys_ni_syscall    /* 275 sys_get_mempolicy */
 883        .long sys_ni_syscall    /* sys_set_mempolicy */
 884        .long sys_mq_open
 885        .long sys_mq_unlink
 886        .long sys_mq_timedsend
 887        .long sys_mq_timedreceive       /* 280 */
 888        .long sys_mq_notify
 889        .long sys_mq_getsetattr
 890        .long sys_ni_syscall
 891        .long sys_waitid
 892        .long sys_ni_syscall            /* 285 */ /* available */
 893        .long sys_add_key
 894        .long sys_request_key
 895        .long sys_keyctl
 896        .long sys_ioprio_set
 897        .long sys_ioprio_get            /* 290 */
 898        .long sys_inotify_init
 899        .long sys_inotify_add_watch
 900        .long sys_inotify_rm_watch
 901        .long sys_migrate_pages
 902        .long sys_openat                /* 295 */
 903        .long sys_mkdirat
 904        .long sys_mknodat
 905        .long sys_fchownat
 906        .long sys_futimesat
 907        .long sys_fstatat64             /* 300 */
 908        .long sys_unlinkat
 909        .long sys_renameat
 910        .long sys_linkat
 911        .long sys_symlinkat
 912        .long sys_readlinkat            /* 305 */
 913        .long sys_fchmodat
 914        .long sys_faccessat
 915        .long sys_pselect6
 916        .long sys_ppoll
 917        .long sys_unshare               /* 310 */
 918        .long sys_set_robust_list
 919        .long sys_get_robust_list
 920        .long sys_splice
 921        .long sys_sync_file_range
 922        .long sys_tee                   /* 315 */
 923        .long sys_vmsplice
 924        .long sys_move_pages
 925        .long sys_getcpu
 926        .long sys_epoll_pwait
 927        .long sys_utimensat             /* 320 */
 928        .long sys_signalfd
 929        .long sys_timerfd_create
 930        .long sys_eventfd
 931        .long sys_fallocate
 932        .long sys_timerfd_settime       /* 325 */
 933        .long sys_timerfd_gettime
 934        .long sys_signalfd4
 935        .long sys_eventfd2
 936        .long sys_epoll_create1
 937        .long sys_dup3                  /* 330 */
 938        .long sys_pipe2
 939        .long sys_inotify_init1
 940        .long sys_preadv
 941        .long sys_pwritev
 942        .long sys_setns                 /* 335 */
 943        .long sys_name_to_handle_at
 944        .long sys_open_by_handle_at
 945        .long sys_rt_tgsigqueueinfo
 946        .long sys_perf_event_open
 947        .long sys_recvmmsg              /* 340 */
 948        .long sys_accept4
 949        .long sys_fanotify_init
 950        .long sys_fanotify_mark
 951        .long sys_prlimit64
 952        .long sys_clock_adjtime         /* 345 */
 953        .long sys_syncfs
 954        .long sys_sendmmsg
 955        .long sys_process_vm_readv
 956        .long sys_process_vm_writev
 957        .long sys_kcmp                  /* 350 */
 958        .long sys_finit_module
 959        .long sys_sched_setattr
 960        .long sys_sched_getattr
 961        .long sys_renameat2
 962        .long sys_seccomp               /* 355 */
 963        .long sys_getrandom
 964        .long sys_memfd_create
 965        .long sys_bpf
 966        .long sys_execveat
 967
 968        /*
 969         * NOTE!! This doesn't have to be exact - we just have
 970         * to make sure we have _enough_ of the "sys_ni_syscall"
 971         * entries. Don't panic if you notice that this hasn't
 972         * been shrunk every time we add a new system call.
 973         */
 974
 975        .rept NR_syscalls-(.-sys_call_table)/4
 976                .long sys_ni_syscall
 977        .endr
 978
 979