12e1ae9c0SLiu Yu-B13201/* 22e1ae9c0SLiu Yu-B13201 * Copyright (C) 2012 Freescale Semiconductor, Inc. 32e1ae9c0SLiu Yu-B13201 * 42e1ae9c0SLiu Yu-B13201 * This program is free software; you can redistribute it and/or 52e1ae9c0SLiu Yu-B13201 * modify it under the terms of the GNU General Public License 62e1ae9c0SLiu Yu-B13201 * as published by the Free Software Foundation; either version 72e1ae9c0SLiu Yu-B13201 * 2 of the License, or (at your option) any later version. 82e1ae9c0SLiu Yu-B13201 */ 92e1ae9c0SLiu Yu-B13201 102e1ae9c0SLiu Yu-B13201#include <linux/threads.h> 112f979de8SLiu Yu-B13201#include <asm/epapr_hcalls.h> 122e1ae9c0SLiu Yu-B13201#include <asm/reg.h> 132e1ae9c0SLiu Yu-B13201#include <asm/page.h> 142e1ae9c0SLiu Yu-B13201#include <asm/cputable.h> 152e1ae9c0SLiu Yu-B13201#include <asm/thread_info.h> 162e1ae9c0SLiu Yu-B13201#include <asm/ppc_asm.h> 172f979de8SLiu Yu-B13201#include <asm/asm-compat.h> 182e1ae9c0SLiu Yu-B13201#include <asm/asm-offsets.h> 192e1ae9c0SLiu Yu-B13201 202f979de8SLiu Yu-B13201/* epapr_ev_idle() was derived from e500_idle() */ 212f979de8SLiu Yu-B13201_GLOBAL(epapr_ev_idle) 222f979de8SLiu Yu-B13201 CURRENT_THREAD_INFO(r3, r1) 232f979de8SLiu Yu-B13201 PPC_LL r4, TI_LOCAL_FLAGS(r3) /* set napping bit */ 242f979de8SLiu Yu-B13201 ori r4, r4,_TLF_NAPPING /* so when we take an exception */ 252f979de8SLiu Yu-B13201 PPC_STL r4, TI_LOCAL_FLAGS(r3) /* it will return to our caller */ 262f979de8SLiu Yu-B13201 272f979de8SLiu Yu-B13201 wrteei 1 282f979de8SLiu Yu-B13201 292f979de8SLiu Yu-B13201idle_loop: 302f979de8SLiu Yu-B13201 LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE)) 312f979de8SLiu Yu-B13201 322f979de8SLiu Yu-B13201.global epapr_ev_idle_start 332f979de8SLiu Yu-B13201epapr_ev_idle_start: 342f979de8SLiu Yu-B13201 li r3, -1 352f979de8SLiu Yu-B13201 nop 362f979de8SLiu Yu-B13201 nop 372f979de8SLiu Yu-B13201 nop 382f979de8SLiu Yu-B13201 392f979de8SLiu Yu-B13201 /* 402f979de8SLiu Yu-B13201 * Guard against spurious wakeups from a hypervisor -- 412f979de8SLiu Yu-B13201 * only interrupt will cause us to return to LR due to 422f979de8SLiu Yu-B13201 * _TLF_NAPPING. 432f979de8SLiu Yu-B13201 */ 442f979de8SLiu Yu-B13201 b idle_loop 452f979de8SLiu Yu-B13201 462e1ae9c0SLiu Yu-B13201/* Hypercall entry point. Will be patched with device tree instructions. */ 472e1ae9c0SLiu Yu-B13201.global epapr_hypercall_start 482e1ae9c0SLiu Yu-B13201epapr_hypercall_start: 492e1ae9c0SLiu Yu-B13201 li r3, -1 502e1ae9c0SLiu Yu-B13201 nop 512e1ae9c0SLiu Yu-B13201 nop 522e1ae9c0SLiu Yu-B13201 nop 532e1ae9c0SLiu Yu-B13201 blr 54