3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: ntoskrnl/ke/i386/bthread.S
24 * PURPOSE: Trap handlers
25 * PROGRAMMER: David Welch (david.welch@seh.ox.ac.uk)
28 /* INCLUDES ******************************************************************/
30 #include <ddk/status.h>
31 #include <internal/i386/segment.h>
32 #include <internal/ps.h>
33 #include <ddk/defines.h>
35 /* Values for contextflags */
36 #define CONTEXT_i386 0x10000
37 #ifndef CONTEXT_CONTROL
38 #define CONTEXT_CONTROL (CONTEXT_i386 | 1)
40 #ifndef CONTEXT_INTEGER
41 #define CONTEXT_INTEGER (CONTEXT_i386 | 2)
43 #ifndef CONTEXT_SEGMENTS
44 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 4)
46 #ifndef CONTEXT_FLOATING_POINT
47 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 8)
49 #ifndef CONTEXT_DEBUG_REGISTERS
50 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x10)
53 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
56 /* FUNCTIONS *****************************************************************/
62 .globl _PsBeginThreadWithContextInternal
67 * This isn't really a function, we are called as the return address
68 * of the context switch function
72 * Do the necessary prolog after a context switch
74 call _PiBeforeBeginThread
77 * Call the actual start of the thread
79 movl 4(%esp), %ebx /* Start routine */
80 movl 8(%esp), %eax /* Start context */
82 call *%ebx /* Call the start routine */
86 * Terminate the thread
89 call _PsTerminateSystemThread@4
93 * If that fails then bug check
100 * And if that fails then loop
106 _PsBeginThreadWithContextInternal:
108 * This isn't really a function, we are called as the return
109 * address of a context switch
113 * Do the necessary prolog before the context switch
115 call _PiBeforeBeginThread
118 * Load the context flags.
123 * Load the debugging registers
125 testl $(CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386), %ebx
145 * Load the floating point registers
147 movl (_HardwareMathSupport), %eax
150 testl $(CONTEXT_FLOATING_POINT & ~CONTEXT_i386), %ebx
156 /* Load the rest of the thread's user mode context. */
158 jmp KeReturnFromSystemCallWithHook