Ignore:
Timestamp:
Oct 8, 2008, 9:51:36 AM (12 years ago)
Author:
gb
Message:

FreeBSD x8632 changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/thread_manager.c

    r10953 r11015  
    857857
    858858#ifdef X8632
     859
    859860#ifdef DARWIN
    860861#include <architecture/i386/table.h>
     
    974975
    975976  pthread_mutex_lock(&ldt_lock);
    976   /* load %fs with null segement selector */
     977  /* load %fs with null segment selector */
    977978  __asm__ volatile ("mov %0,%%fs" : : "r"(0));
    978979  tcr->ldt_selector = 0;
     
    10961097}
    10971098
     1099#endif
     1100#ifdef FREEBSD
     1101#include <machine/segments.h>
     1102#include <machine/sysarch.h>
     1103
     1104/* It'd be tempting to use i386_set_fsbase() here, but there doesn't
     1105   seem to be any way to free the GDT entry it creates. */
     1106void
     1107setup_tcr_extra_segment(TCR *tcr)
     1108{
     1109  struct segment_descriptor sd;
     1110  uintptr_t addr = (uintptr_t)tcr;
     1111  unsigned int size = sizeof(*tcr);
     1112  int i;
     1113
     1114  sd.sd_lolimit = (size - 1) & 0xffff;
     1115  sd.sd_hilimit = ((size - 1) >> 16) & 0xf;
     1116  sd.sd_lobase = addr & ((1<<24)-1);
     1117  sd.sd_type = 18;
     1118  sd.sd_dpl = SEL_UPL;
     1119  sd.sd_p = 1;
     1120  sd.sd_def32 = 1;
     1121  sd.sd_gran = 0;
     1122
     1123  i = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)&sd, 1);
     1124
     1125  if (i < 0) {
     1126    perror("i386_set_ldt");
     1127  } else {
     1128    tcr->ldt_selector = LSEL(i,SEL_UPL);
     1129  }
     1130}
     1131
     1132void
     1133free_tcr_extra_segment(TCR *tcr)
     1134{
     1135  int idx = tcr->ldt_selector >> 3;
     1136  /* load %fs with null segment selector */
     1137  __asm__ volatile ("mov %0,%%fs" : : "r"(0));
     1138  if (i386_set_ldt(idx, NULL, 1) < 0)
     1139    perror("i386_set_ldt");
     1140  tcr->ldt_selector = 0;
     1141}
    10981142#endif
    10991143#endif
Note: See TracChangeset for help on using the changeset viewer.