blob: 101de132e363bec669ac5e542c9afd78d172b304 [file] [log] [blame]
Chris Metcalf867e3592010-05-28 23:09:12 -04001/*
2 * Copyright 2010 Tilera Corporation. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11 * NON INFRINGEMENT. See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/linkage.h>
Chris Metcalf0707ad32010-06-25 17:04:17 -040016#include <linux/unistd.h>
Chris Metcalf867e3592010-05-28 23:09:12 -040017#include <asm/irqflags.h>
Chris Metcalfa78c9422010-10-14 16:23:03 -040018#include <asm/processor.h>
Chris Metcalf0707ad32010-06-25 17:04:17 -040019#include <arch/abi.h>
Chris Metcalfa78c9422010-10-14 16:23:03 -040020#include <arch/spr_def.h>
Chris Metcalf867e3592010-05-28 23:09:12 -040021
22#ifdef __tilegx__
23#define bnzt bnezt
24#endif
25
26STD_ENTRY(current_text_addr)
27 { move r0, lr; jrp lr }
28 STD_ENDPROC(current_text_addr)
29
Chris Metcalf867e3592010-05-28 23:09:12 -040030STD_ENTRY(KBacktraceIterator_init_current)
31 { move r2, lr; lnk r1 }
32 { move r4, r52; addli r1, r1, KBacktraceIterator_init_current - . }
33 { move r3, sp; j _KBacktraceIterator_init_current }
34 jrp lr /* keep backtracer happy */
35 STD_ENDPROC(KBacktraceIterator_init_current)
36
Chris Metcalf867e3592010-05-28 23:09:12 -040037/* Loop forever on a nap during SMP boot. */
38STD_ENTRY(smp_nap)
39 nap
Chris Metcalf8c92ba62012-03-29 15:57:18 -040040 nop /* avoid provoking the icache prefetch with a jump */
Chris Metcalf867e3592010-05-28 23:09:12 -040041 j smp_nap /* we are not architecturally guaranteed not to exit nap */
42 jrp lr /* clue in the backtracer */
43 STD_ENDPROC(smp_nap)
44
45/*
46 * Enable interrupts racelessly and then nap until interrupted.
Chris Metcalf0b989ca2011-02-28 15:22:40 -050047 * Architecturally, we are guaranteed that enabling interrupts via
48 * mtspr to INTERRUPT_CRITICAL_SECTION only interrupts at the next PC.
Chris Metcalf867e3592010-05-28 23:09:12 -040049 * This function's _cpu_idle_nap address is special; see intvec.S.
50 * When interrupted at _cpu_idle_nap, we bump the PC forward 8, and
51 * as a result return to the function that called _cpu_idle().
52 */
Chris Metcalf6727ad92016-10-07 17:02:55 -070053STD_ENTRY_SECTION(_cpu_idle, .cpuidle.text)
Chris Metcalf0b989ca2011-02-28 15:22:40 -050054 movei r1, 1
Chris Metcalf51007002012-03-27 15:40:20 -040055 IRQ_ENABLE_LOAD(r2, r3)
Chris Metcalf0b989ca2011-02-28 15:22:40 -050056 mtspr INTERRUPT_CRITICAL_SECTION, r1
Chris Metcalf51007002012-03-27 15:40:20 -040057 IRQ_ENABLE_APPLY(r2, r3) /* unmask, but still with ICS set */
Chris Metcalf0b989ca2011-02-28 15:22:40 -050058 mtspr INTERRUPT_CRITICAL_SECTION, zero
Chris Metcalf867e3592010-05-28 23:09:12 -040059 .global _cpu_idle_nap
60_cpu_idle_nap:
61 nap
Chris Metcalf8c92ba62012-03-29 15:57:18 -040062 nop /* avoid provoking the icache prefetch with a jump */
Chris Metcalf867e3592010-05-28 23:09:12 -040063 jrp lr
64 STD_ENDPROC(_cpu_idle)