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 #define CONTEXT_CONTROL (CONTEXT_i386 | 1)
38 #define CONTEXT_INTEGER (CONTEXT_i386 | 2)
39 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 4)
40 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 8)
41 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x10)
42 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
44 /* FUNCTIONS *****************************************************************/
50 .globl _PsBeginThreadWithContextInternal
55 * This isn't really a function, we are called as the return address
56 * of the context switch function
60 * Do the necessary prolog after a context switch
62 call _PiBeforeBeginThread
65 * Call the actual start of the thread
67 movl 4(%esp), %ebx /* Start routine */
68 movl 8(%esp), %eax /* Start context */
70 call *%ebx /* Call the start routine */
74 * Terminate the thread
77 call _PsTerminateSystemThread@4
81 * If that fails then bug check
88 * And if that fails then loop
94 _PsBeginThreadWithContextInternal:
96 * This isn't really a function, we are called as the return
97 * address of a context switch
101 * Do the necessary prolog before the context switch
103 call _PiBeforeBeginThread
106 * Load the context flags.
111 * Load the debugging registers
113 testl $CONTEXT_DEBUG_REGISTERS, %ebx
133 * Load the floating point registers
135 movl (_HardwareMathSupport), %eax
137 testl $CONTEXT_FLOATING_POINT, %ebx
143 /* Load the rest of the thread's user mode context. */
145 jmp KeReturnFromSystemCallWithHook