1284257Sbr/*- 2284257Sbr * Copyright (c) 2015 The FreeBSD Foundation 3284257Sbr * All rights reserved. 4284257Sbr * 5284257Sbr * This software was developed by Semihalf under 6284257Sbr * the sponsorship of the FreeBSD Foundation. 7284257Sbr * 8284257Sbr * Redistribution and use in source and binary forms, with or without 9284257Sbr * modification, are permitted provided that the following conditions 10284257Sbr * are met: 11284257Sbr * 1. Redistributions of source code must retain the above copyright 12284257Sbr * notice, this list of conditions and the following disclaimer. 13284257Sbr * 2. Redistributions in binary form must reproduce the above copyright 14284257Sbr * notice, this list of conditions and the following disclaimer in the 15284257Sbr * documentation and/or other materials provided with the distribution. 16284257Sbr * 17284257Sbr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18284257Sbr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19284257Sbr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20284257Sbr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21284257Sbr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22284257Sbr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23284257Sbr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24284257Sbr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25284257Sbr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26284257Sbr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27284257Sbr * SUCH DAMAGE. 28284257Sbr */ 29284257Sbr 30284257Sbr#include <sys/cdefs.h> 31284257Sbr__FBSDID("$FreeBSD$"); 32284257Sbr#include <sys/param.h> 33284257Sbr 34284257Sbr#include <machine/stack.h> 35287113Sandrew#include <machine/vmparam.h> 36284257Sbr 37284257Sbrint 38284257Sbrunwind_frame(struct unwind_state *frame) 39284257Sbr{ 40284257Sbr uint64_t fp; 41284257Sbr 42284257Sbr fp = frame->fp; 43287113Sandrew if (!INKERNEL(fp)) 44284257Sbr return (-1); 45284257Sbr 46284257Sbr frame->sp = fp + 0x10; 47284257Sbr /* FP to previous frame (X29) */ 48284257Sbr frame->fp = *(uint64_t *)(fp); 49284257Sbr /* LR (X30) */ 50284257Sbr frame->pc = *(uint64_t *)(fp + 8) - 4; 51284257Sbr 52284257Sbr return (0); 53284257Sbr} 54