Subversion Repositories HelenOS

Rev

Rev 2286 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (c) 2007 Michal Kebrt
  3.  * Copyright (c) 2007 Petr Stepan
  4.  *
  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.  *
  11.  * - Redistributions of source code must retain the above copyright
  12.  *   notice, this list of conditions and the following disclaimer.
  13.  * - Redistributions in binary form must reproduce the above copyright
  14.  *   notice, this list of conditions and the following disclaimer in the
  15.  *   documentation and/or other materials provided with the distribution.
  16.  * - The name of the author may not be used to endorse or promote products
  17.  *   derived from this software without specific prior written permission.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  20.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  23.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29.  */
  30.  
  31. /** @addtogroup arm32  
  32.  * @{
  33.  */
  34. /** @file
  35.  */
  36.  
  37. #ifndef KERN_arm32_EXCEPTION_H_
  38. #define KERN_arm32_EXCEPTION_H_
  39.  
  40. #include <arch/types.h>
  41. #include <arch/regutils.h>
  42.  
  43. #define HIGH_EXCEPTION_VECTORS
  44.  
  45. #ifdef HIGH_EXCEPTION_VECTORS
  46.     #define EXC_BASE_ADDRESS    0xffff0000
  47. #else
  48.     #define EXC_BASE_ADDRESS    0x0
  49. #endif
  50.  
  51. /* Exception Vectors */
  52. #define EXC_RESET_VEC       (EXC_BASE_ADDRESS + 0x0)
  53. #define EXC_UNDEF_INSTR_VEC (EXC_BASE_ADDRESS + 0x4)
  54. #define EXC_SWI_VEC     (EXC_BASE_ADDRESS + 0x8)
  55. #define EXC_PREFETCH_ABORT_VEC  (EXC_BASE_ADDRESS + 0xc)
  56. #define EXC_DATA_ABORT_VEC  (EXC_BASE_ADDRESS + 0x10)
  57. #define EXC_IRQ_VEC     (EXC_BASE_ADDRESS + 0x18)
  58. #define EXC_FIQ_VEC     (EXC_BASE_ADDRESS + 0x1c)
  59.  
  60. /* Exception numbers */
  61. #define EXC_RESET       0
  62. #define EXC_UNDEF_INSTR     1
  63. #define EXC_SWI         2
  64. #define EXC_PREFETCH_ABORT  3
  65. #define EXC_DATA_ABORT      4
  66. #define EXC_IRQ         5
  67. #define EXC_FIQ         6
  68.  
  69. typedef struct {
  70.         uint32_t spsr;
  71.     uint32_t sp;
  72.     uint32_t lr;
  73.  
  74.         uint32_t r0;
  75.         uint32_t r1;
  76.         uint32_t r2;
  77.         uint32_t r3;
  78.         uint32_t r4;
  79.         uint32_t r5;
  80.         uint32_t r6;
  81.         uint32_t r7;
  82.         uint32_t r8;
  83.         uint32_t r9;
  84.         uint32_t r10;
  85.         uint32_t r11;
  86.         uint32_t r12;
  87.  
  88.         uint32_t pc;
  89. } istate_t;
  90.  
  91.  
  92.  
  93. static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr)
  94. {
  95.     istate->pc = retaddr;
  96. }
  97.  
  98. /** Return true if exception happened while in userspace */
  99. static inline int istate_from_uspace(istate_t *istate)
  100. {
  101.     return (istate->spsr & STATUS_REG_MODE_MASK) == USER_MODE;
  102. }
  103. static inline unative_t istate_get_pc(istate_t *istate)
  104. {
  105.     return istate->pc;
  106. }
  107.  
  108. extern void setup_exception_stacks(void);
  109. extern void install_exception_handlers(void);
  110. extern void exception_init(void);
  111.  
  112. #endif
  113.  
  114. /** @}
  115.  */
  116.