15c48b108SAl Viro /*
25c48b108SAl Viro * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
35c48b108SAl Viro * Licensed under the GPL
45c48b108SAl Viro */
55c48b108SAl Viro
65c48b108SAl Viro #ifndef __UM_PROCESSOR_I386_H
75c48b108SAl Viro #define __UM_PROCESSOR_I386_H
85c48b108SAl Viro
95c48b108SAl Viro #include <linux/string.h>
105c48b108SAl Viro #include <asm/segment.h>
11b3ee571eSAl Viro #include <asm/ldt.h>
125c48b108SAl Viro
135c48b108SAl Viro extern int host_has_cmov;
145c48b108SAl Viro
155c48b108SAl Viro struct uml_tls_struct {
165c48b108SAl Viro struct user_desc tls;
175c48b108SAl Viro unsigned flushed:1;
185c48b108SAl Viro unsigned present:1;
195c48b108SAl Viro };
205c48b108SAl Viro
215c48b108SAl Viro struct arch_thread {
225c48b108SAl Viro struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
235c48b108SAl Viro unsigned long debugregs[8];
245c48b108SAl Viro int debugregs_seq;
255c48b108SAl Viro struct faultinfo faultinfo;
265c48b108SAl Viro };
275c48b108SAl Viro
285c48b108SAl Viro #define INIT_ARCH_THREAD { \
295c48b108SAl Viro .tls_array = { [ 0 ... GDT_ENTRY_TLS_ENTRIES - 1 ] = \
305c48b108SAl Viro { .present = 0, .flushed = 0 } }, \
315c48b108SAl Viro .debugregs = { [ 0 ... 7 ] = 0 }, \
325c48b108SAl Viro .debugregs_seq = 0, \
335c48b108SAl Viro .faultinfo = { 0, 0, 0 } \
345c48b108SAl Viro }
355c48b108SAl Viro
36*9d1ee8ceSRichard Weinberger #define STACKSLOTS_PER_LINE 8
37*9d1ee8ceSRichard Weinberger
arch_flush_thread(struct arch_thread * thread)385c48b108SAl Viro static inline void arch_flush_thread(struct arch_thread *thread)
395c48b108SAl Viro {
405c48b108SAl Viro /* Clear any TLS still hanging */
415c48b108SAl Viro memset(&thread->tls_array, 0, sizeof(thread->tls_array));
425c48b108SAl Viro }
435c48b108SAl Viro
arch_copy_thread(struct arch_thread * from,struct arch_thread * to)445c48b108SAl Viro static inline void arch_copy_thread(struct arch_thread *from,
455c48b108SAl Viro struct arch_thread *to)
465c48b108SAl Viro {
475c48b108SAl Viro memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array));
485c48b108SAl Viro }
495c48b108SAl Viro
50*9d1ee8ceSRichard Weinberger #define current_sp() ({ void *sp; __asm__("movl %%esp, %0" : "=r" (sp) : ); sp; })
51*9d1ee8ceSRichard Weinberger #define current_bp() ({ unsigned long bp; __asm__("movl %%ebp, %0" : "=r" (bp) : ); bp; })
52*9d1ee8ceSRichard Weinberger
535c48b108SAl Viro #endif
54