patch-2.4.8 linux/arch/ia64/ia32/ia32_support.c
Next file: linux/arch/ia64/ia32/sys_ia32.c
Previous file: linux/arch/ia64/ia32/ia32_ldt.c
Back to the patch index
Back to the overall index
- Lines: 143
- Date:
Tue Jul 31 10:30:08 2001
- Orig file:
v2.4.7/linux/arch/ia64/ia32/ia32_support.c
- Orig date:
Thu Apr 5 12:51:47 2001
diff -u --recursive --new-file v2.4.7/linux/arch/ia64/ia32/ia32_support.c linux/arch/ia64/ia32/ia32_support.c
@@ -1,6 +1,11 @@
/*
* IA32 helper functions
*
+ * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
+ * Copyright (C) 2000 Asit K. Mallick <asit.k.mallick@intel.com>
+ * Copyright (C) 2001 Hewlett-Packard Co
+ * Copyright (C) 2001 David Mosberger-Tang <davidm@hpl.hp.com>
+ *
* 06/16/00 A. Mallick added csd/ssd/tssd for ia32 thread context
* 02/19/01 D. Mosberger dropped tssd; it's not needed
*/
@@ -21,7 +26,7 @@
extern void die_if_kernel (char *str, struct pt_regs *regs, long err);
void
-ia32_save_state (struct thread_struct *thread)
+ia32_save_state (struct task_struct *t)
{
unsigned long eflag, fsr, fcr, fir, fdr, csd, ssd;
@@ -33,28 +38,30 @@
"mov %5=ar.csd;"
"mov %6=ar.ssd;"
: "=r"(eflag), "=r"(fsr), "=r"(fcr), "=r"(fir), "=r"(fdr), "=r"(csd), "=r"(ssd));
- thread->eflag = eflag;
- thread->fsr = fsr;
- thread->fcr = fcr;
- thread->fir = fir;
- thread->fdr = fdr;
- thread->csd = csd;
- thread->ssd = ssd;
- asm ("mov ar.k0=%0 ;;" :: "r"(thread->old_iob));
+ t->thread.eflag = eflag;
+ t->thread.fsr = fsr;
+ t->thread.fcr = fcr;
+ t->thread.fir = fir;
+ t->thread.fdr = fdr;
+ t->thread.csd = csd;
+ t->thread.ssd = ssd;
+ ia64_set_kr(IA64_KR_IO_BASE, t->thread.old_iob);
}
void
-ia32_load_state (struct thread_struct *thread)
+ia32_load_state (struct task_struct *t)
{
unsigned long eflag, fsr, fcr, fir, fdr, csd, ssd;
+ struct pt_regs *regs = ia64_task_regs(t);
+ int nr;
- eflag = thread->eflag;
- fsr = thread->fsr;
- fcr = thread->fcr;
- fir = thread->fir;
- fdr = thread->fdr;
- csd = thread->csd;
- ssd = thread->ssd;
+ eflag = t->thread.eflag;
+ fsr = t->thread.fsr;
+ fcr = t->thread.fcr;
+ fir = t->thread.fir;
+ fdr = t->thread.fdr;
+ csd = t->thread.csd;
+ ssd = t->thread.ssd;
asm volatile ("mov ar.eflag=%0;"
"mov ar.fsr=%1;"
@@ -64,17 +71,22 @@
"mov ar.csd=%5;"
"mov ar.ssd=%6;"
:: "r"(eflag), "r"(fsr), "r"(fcr), "r"(fir), "r"(fdr), "r"(csd), "r"(ssd));
- asm ("mov %0=ar.k0 ;;" : "=r"(thread->old_iob));
- asm ("mov ar.k0=%0 ;;" :: "r"(IA32_IOBASE));
+ current->thread.old_iob = ia64_get_kr(IA64_KR_IO_BASE);
+ ia64_set_kr(IA64_KR_IO_BASE, IA32_IOBASE);
+
+ /* load TSS and LDT while preserving SS and CS: */
+ nr = smp_processor_id();
+ regs->r17 = (_TSS(nr) << 48) | (_LDT(nr) << 32) | (__u32) regs->r17;
}
/*
- * Setup IA32 GDT and TSS
+ * Setup IA32 GDT and TSS
*/
void
-ia32_gdt_init(void)
+ia32_gdt_init (void)
{
- unsigned long gdt_and_tss_page;
+ unsigned long gdt_and_tss_page, ldt_size;
+ int nr;
/* allocate two IA-32 pages of memory: */
gdt_and_tss_page = __get_free_pages(GFP_KERNEL,
@@ -86,17 +98,28 @@
/* Zero the gdt and tss */
memset((void *) gdt_and_tss_page, 0, 2*IA32_PAGE_SIZE);
- /* CS descriptor in IA-32 format */
- ia32_gdt_table[4] = IA32_SEG_DESCRIPTOR(0L, 0xBFFFFFFFL, 0xBL, 1L,
- 3L, 1L, 1L, 1L, 1L);
-
- /* DS descriptor in IA-32 format */
- ia32_gdt_table[5] = IA32_SEG_DESCRIPTOR(0L, 0xBFFFFFFFL, 0x3L, 1L,
- 3L, 1L, 1L, 1L, 1L);
+ /* CS descriptor in IA-32 (scrambled) format */
+ ia32_gdt_table[__USER_CS >> 3] =
+ IA32_SEG_DESCRIPTOR(0, (IA32_PAGE_OFFSET - 1) >> IA32_PAGE_SHIFT,
+ 0xb, 1, 3, 1, 1, 1, 1);
+
+ /* DS descriptor in IA-32 (scrambled) format */
+ ia32_gdt_table[__USER_DS >> 3] =
+ IA32_SEG_DESCRIPTOR(0, (IA32_PAGE_OFFSET - 1) >> IA32_PAGE_SHIFT,
+ 0x3, 1, 3, 1, 1, 1, 1);
+
+ /* We never change the TSS and LDT descriptors, so we can share them across all CPUs. */
+ ldt_size = PAGE_ALIGN(IA32_LDT_ENTRIES*IA32_LDT_ENTRY_SIZE);
+ for (nr = 0; nr < NR_CPUS; ++nr) {
+ ia32_gdt_table[_TSS(nr)] = IA32_SEG_DESCRIPTOR(IA32_TSS_OFFSET, 235,
+ 0xb, 0, 3, 1, 1, 1, 0);
+ ia32_gdt_table[_LDT(nr)] = IA32_SEG_DESCRIPTOR(IA32_LDT_OFFSET, ldt_size - 1,
+ 0x2, 0, 3, 1, 1, 1, 0);
+ }
}
/*
- * Handle bad IA32 interrupt via syscall
+ * Handle bad IA32 interrupt via syscall
*/
void
ia32_bad_interrupt (unsigned long int_num, struct pt_regs *regs)
@@ -106,8 +129,7 @@
die_if_kernel("Bad IA-32 interrupt", regs, int_num);
siginfo.si_signo = SIGTRAP;
- siginfo.si_errno = int_num; /* XXX is it legal to abuse si_errno like this? */
+ siginfo.si_errno = int_num; /* XXX is it OK to abuse si_errno like this? */
siginfo.si_code = TRAP_BRKPT;
force_sig_info(SIGTRAP, &siginfo, current);
}
-
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)