source: mainline/kernel/arch/ia32/include/istate.h@ efedee77

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since efedee77 was 598f90e, checked in by Jiri Svoboda <jiri@…>, 15 years ago

Use istate_t definitions from kernel instead of duplicating them.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2001-2004 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup ia32interrupt
30 * @{
31 */
32/** @file
33 */
34
35#ifndef KERN_ia32_ISTATE_H_
36#define KERN_ia32_ISTATE_H_
37
38#ifdef KERNEL
39#include <typedefs.h>
40#include <trace.h>
41#else
42#include <sys/types.h>
43#define NO_TRACE
44#endif
45
46typedef struct istate {
47 /*
48 * The strange order of the GPRs is given by the requirement to use the
49 * istate structure for both regular interrupts and exceptions as well
50 * as for syscall handlers which use this order as an optimization.
51 */
52 uint32_t edx;
53 uint32_t ecx;
54 uint32_t ebx;
55 uint32_t esi;
56 uint32_t edi;
57 uint32_t ebp;
58 uint32_t eax;
59
60 uint32_t ebp_frame; /* imitation of frame pointer linkage */
61 uint32_t eip_frame; /* imitation of return address linkage */
62
63 uint32_t gs;
64 uint32_t fs;
65 uint32_t es;
66 uint32_t ds;
67
68 uint32_t error_word; /* real or fake error word */
69 uint32_t eip;
70 uint32_t cs;
71 uint32_t eflags;
72 uint32_t esp; /* only if istate_t is from uspace */
73 uint32_t ss; /* only if istate_t is from uspace */
74} istate_t;
75
76/** Return true if exception happened while in userspace */
77NO_TRACE static inline int istate_from_uspace(istate_t *istate)
78{
79 return !(istate->eip & 0x80000000);
80}
81
82NO_TRACE static inline void istate_set_retaddr(istate_t *istate,
83 uintptr_t retaddr)
84{
85 istate->eip = retaddr;
86}
87
88NO_TRACE static inline uintptr_t istate_get_pc(istate_t *istate)
89{
90 return istate->eip;
91}
92
93NO_TRACE static inline uintptr_t istate_get_fp(istate_t *istate)
94{
95 return istate->ebp;
96}
97
98#endif
99
100/** @}
101 */
Note: See TracBrowser for help on using the repository browser.