| [16] | 1 | /* |
|---|
| 2 | * do_exception.h - Architecture independant exception handler definition. |
|---|
| 3 | * |
|---|
| 4 | * Author Ghassan Almaless (2008,2009,2010,2011,2012) |
|---|
| 5 | * Mohamed Lamine Karaoui (2015) |
|---|
| 6 | * Alain Greiner (2016) |
|---|
| 7 | * |
|---|
| 8 | * Copyright (c) UPMC Sorbonne Universites |
|---|
| 9 | * |
|---|
| 10 | * This file is part of ALMOS-MKH. |
|---|
| 11 | * |
|---|
| 12 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
|---|
| 13 | * under the terms of the GNU General Public License as published by |
|---|
| 14 | * the Free Software Foundation; version 2.0 of the License. |
|---|
| 15 | * |
|---|
| 16 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
|---|
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 19 | * General Public License for more details. |
|---|
| 20 | * |
|---|
| 21 | * You should have received a copy of the GNU General Public License |
|---|
| 22 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
|---|
| 23 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 24 | */ |
|---|
| 25 | |
|---|
| 26 | #ifndef _DO_EXCEPTION_H_ |
|---|
| 27 | #define _DO_EXCEPTION_H_ |
|---|
| 28 | |
|---|
| 29 | #include <hal_types.h> |
|---|
| 30 | #include <thread.h> |
|---|
| 31 | |
|---|
| 32 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 33 | // This file defines the architecture independant exception handler. |
|---|
| 34 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 35 | |
|---|
| 36 | /************************************************************************************** |
|---|
| 37 | * This enum defines the various error codes returned by this generic |
|---|
| 38 | * exception handler to the architecture specific exception handler. |
|---|
| 39 | *************************************************************************************/ |
|---|
| 40 | |
|---|
| 41 | typedef enum |
|---|
| 42 | { |
|---|
| 43 | EXCP_NON_FATAL = 0, // page fault of FPU unusable handled => non fatal |
|---|
| 44 | EXCP_USER_ERROR = 1, // User error => user process will receive a SIGSEGV |
|---|
| 45 | EXCP_KERNEL_PANIC = 2, // Kernel error => kernel panic |
|---|
| 46 | } |
|---|
| 47 | excp_classes_t; |
|---|
| 48 | |
|---|
| 49 | /************************************************************************************** |
|---|
| 50 | * This defines the masks used to analyse the MMU exception code |
|---|
| 51 | * TODO : these values have been defined to fit the TSAR MMU, |
|---|
| 52 | * but a more generic abstraction must be defined... |
|---|
| 53 | *************************************************************************************/ |
|---|
| 54 | |
|---|
| 55 | #define MMU_EXCP_PAGE_UNMAPPED 0x0003 // page fault (PTE unmapped) |
|---|
| 56 | #define MMU_EXCP_USER_PRIVILEGE 0x0004 // user access to a kernel segment |
|---|
| 57 | #define MMU_EXCP_USER_WRITE 0x0008 // user access to non writable segment |
|---|
| 58 | #define MMU_EXCP_USER_EXEC 0x0010 // user access to non executable segment |
|---|
| 59 | |
|---|
| 60 | /************************************************************************************** |
|---|
| 61 | * This function is called by the hal_do_exception() function associated to a specific |
|---|
| 62 | * hardware architecture. |
|---|
| 63 | * The fatal errors are mostly handled by the architecture specific handler, |
|---|
| 64 | * and this generic handler handles only two non fatal exceptions types: |
|---|
| 65 | * - MMU page fault |
|---|
| 66 | * - FPU unavailable |
|---|
| 67 | * As some MMU exceptions can be fatal, the returned error code can take three values: |
|---|
| 68 | * - Non Fatal Exception |
|---|
| 69 | * - Fatal User Error |
|---|
| 70 | * - Kernel Panic Error |
|---|
| 71 | ************************************************************************************** |
|---|
| 72 | * @ this : pointer on the faulty (user) thread descriptor. |
|---|
| 73 | * @ is_mmu : MMU exception if true / FPU exception if false |
|---|
| 74 | * @ return an error code in [EXCP_NON_FATAL / EXCP_USER_ERROR / EXCP_KERNEL_PANIC] |
|---|
| 75 | *************************************************************************************/ |
|---|
| 76 | error_t do_exception( thread_t * this, |
|---|
| 77 | bool_t is_mmu ); |
|---|
| 78 | |
|---|
| 79 | #endif /* _DO_EXCEPTION_H_ */ |
|---|