ia32_exception.S revision 129630
1114987Speter/*- 2114987Speter * Copyright (c) 2003 Peter Wemm 3114987Speter * All rights reserved. 4114987Speter * 5114987Speter * Redistribution and use in source and binary forms, with or without 6114987Speter * modification, are permitted provided that the following conditions 7114987Speter * are met: 8114987Speter * 1. Redistributions of source code must retain the above copyright 9114987Speter * notice, this list of conditions and the following disclaimer. 10114987Speter * 2. Redistributions in binary form must reproduce the above copyright 11114987Speter * notice, this list of conditions and the following disclaimer in the 12114987Speter * documentation and/or other materials provided with the distribution. 13114987Speter * 14114987Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15114987Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16114987Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17114987Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18114987Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19114987Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20114987Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21114987Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22114987Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23114987Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24114987Speter * SUCH DAMAGE. 25114987Speter * 26114987Speter * $FreeBSD: head/sys/amd64/ia32/ia32_exception.S 129630 2004-05-23 19:06:15Z bde $ 27114987Speter */ 28114987Speter 29114987Speter#include <machine/asmacros.h> 30114987Speter 31114987Speter#include "assym.s" 32114987Speter 33114987Speter#define IDTVEC(name) ALIGN_TEXT; .globl __CONCAT(X,name); \ 34114987Speter .type __CONCAT(X,name),@function; __CONCAT(X,name): 35114987Speter 36114987Speter .text 37114987Speter/* 38114987Speter * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80) 39114987Speter * 40114987Speter * This is a SDT_SYSIDT entry point (unlike the i386 port) so that we 41114987Speter * can do a swapgs before enabling interrupts. This is critical because 42114987Speter * if we took an interrupt before swapgs, the interrupt code would see 43114987Speter * that it originated in supervisor mode and skip the swapgs. 44114987Speter */ 45114987Speter SUPERALIGN_TEXT 46114987SpeterIDTVEC(int0x80_syscall) 47114987Speter swapgs 48114987Speter sti 49114987Speter pushq $2 /* sizeof "int 0x80" */ 50114987Speter subq $TF_ERR,%rsp /* skip over tf_trapno */ 51114987Speter movq %rdi,TF_RDI(%rsp) 52114987Speter movq %rsi,TF_RSI(%rsp) 53114987Speter movq %rdx,TF_RDX(%rsp) 54114987Speter movq %rcx,TF_RCX(%rsp) 55114987Speter movq %r8,TF_R8(%rsp) 56114987Speter movq %r9,TF_R9(%rsp) 57114987Speter movq %rax,TF_RAX(%rsp) 58114987Speter movq %rbx,TF_RBX(%rsp) 59114987Speter movq %rbp,TF_RBP(%rsp) 60114987Speter movq %r10,TF_R10(%rsp) 61114987Speter movq %r11,TF_R11(%rsp) 62114987Speter movq %r12,TF_R12(%rsp) 63114987Speter movq %r13,TF_R13(%rsp) 64114987Speter movq %r14,TF_R14(%rsp) 65114987Speter movq %r15,TF_R15(%rsp) 66129630Sbde FAKE_MCOUNT(TF_RIP(%rsp)) 67114987Speter call ia32_syscall 68129630Sbde MEXITCOUNT 69114987Speter jmp doreti 70