The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/x86/linux/linux_x86.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 1994-1996 Søren Schmidt
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  */
   28 
   29 #include <sys/cdefs.h>
   30 __FBSDID("$FreeBSD$");
   31 
   32 #include <sys/param.h>
   33 #include <sys/signal.h>
   34 #include <x86/trap.h>
   35 
   36 #include <x86/linux/linux_x86.h>
   37 
   38 #define LINUX_T_UNKNOWN  255
   39 static int _bsd_to_linux_trapcode[] = {
   40         LINUX_T_UNKNOWN,        /* 0 */
   41         6,                      /* 1  T_PRIVINFLT */
   42         LINUX_T_UNKNOWN,        /* 2 */
   43         3,                      /* 3  T_BPTFLT */
   44         LINUX_T_UNKNOWN,        /* 4 */
   45         LINUX_T_UNKNOWN,        /* 5 */
   46         16,                     /* 6  T_ARITHTRAP */
   47         254,                    /* 7  T_ASTFLT */
   48         LINUX_T_UNKNOWN,        /* 8 */
   49         13,                     /* 9  T_PROTFLT */
   50         1,                      /* 10 T_TRCTRAP */
   51         LINUX_T_UNKNOWN,        /* 11 */
   52         14,                     /* 12 T_PAGEFLT */
   53         LINUX_T_UNKNOWN,        /* 13 */
   54         17,                     /* 14 T_ALIGNFLT */
   55         LINUX_T_UNKNOWN,        /* 15 */
   56         LINUX_T_UNKNOWN,        /* 16 */
   57         LINUX_T_UNKNOWN,        /* 17 */
   58         0,                      /* 18 T_DIVIDE */
   59         2,                      /* 19 T_NMI */
   60         4,                      /* 20 T_OFLOW */
   61         5,                      /* 21 T_BOUND */
   62         7,                      /* 22 T_DNA */
   63         8,                      /* 23 T_DOUBLEFLT */
   64         9,                      /* 24 T_FPOPFLT */
   65         10,                     /* 25 T_TSSFLT */
   66         11,                     /* 26 T_SEGNPFLT */
   67         12,                     /* 27 T_STKFLT */
   68         18,                     /* 28 T_MCHK */
   69         19,                     /* 29 T_XMMFLT */
   70         15                      /* 30 T_RESERVED */
   71 };
   72 
   73 /*
   74  * If FreeBSD & Linux have a difference of opinion about what a trap
   75  * means, deal with it here.
   76  */
   77 int
   78 linux_translate_traps(int signal, int trap_code)
   79 {
   80         if (signal != SIGBUS)
   81                 return (signal);
   82         switch (trap_code) {
   83         case T_PROTFLT:
   84         case T_TSSFLT:
   85         case T_DOUBLEFLT:
   86         case T_PAGEFLT:
   87                 return (SIGSEGV);
   88         default:
   89                 return (signal);
   90         }
   91 }
   92 
   93 int
   94 bsd_to_linux_trapcode(int code)
   95 {
   96 
   97         return (code < nitems(_bsd_to_linux_trapcode) ?
   98             _bsd_to_linux_trapcode[code] : LINUX_T_UNKNOWN);

Cache object: 0b9d76cffc7e9147aa3891873140411c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.