Changeset 10102


Ignore:
Timestamp:
Jul 18, 2008, 7:55:48 PM (11 years ago)
Author:
rme
Message:

Additions for Darwin/x8632.

File:
1 edited

Legend:

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

    r10024 r10102  
    726726#endif
    727727
    728 
     728#ifdef X8632
     729#ifdef DARWIN
     730#include <architecture/i386/table.h>
     731#include <architecture/i386/sel.h>
     732#include <i386/user_ldt.h>
     733
     734void setup_tcr_extra_segment(TCR *tcr)
     735{
     736    uintptr_t addr = (uintptr_t)tcr;
     737    unsigned int size = sizeof(*tcr);
     738    ldt_entry_t desc;
     739    sel_t sel;
     740    int i;
     741
     742    desc.data.limit00 = (size - 1) & 0xffff;
     743    desc.data.limit16 = ((size - 1) >> 16) & 0xf;
     744    desc.data.base00 = addr & 0xffff;
     745    desc.data.base16 = (addr >> 16) & 0xff;
     746    desc.data.base24 = (addr >> 24) & 0xff;
     747    desc.data.type = DESC_DATA_WRITE;
     748    desc.data.dpl = USER_PRIV;
     749    desc.data.present = 1;
     750    desc.data.stksz = DESC_CODE_32B;
     751    desc.data.granular = DESC_GRAN_BYTE;
     752   
     753    i = i386_set_ldt(LDT_AUTO_ALLOC, &desc, 1);
     754
     755    if (i < 0) {
     756        perror("i386_set_ldt");
     757    } else {
     758        sel.index = i;
     759        sel.rpl = USER_PRIV;
     760        sel.ti = SEL_LDT;
     761        tcr->ldt_selector = sel;
     762    }
     763}
     764
     765void free_tcr_extra_segment(TCR *tcr)
     766{
     767  /* load %fs with null segement selector */
     768  __asm__ volatile ("mov %0,%%fs" : : "r"(0));
     769  if (i386_set_ldt(tcr->ldt_selector.index, NULL, 1) < 0)
     770    perror("i386_set_ldt");
     771  tcr->ldt_selector = NULL_SEL;
     772}
     773#endif
     774#endif
    729775
    730776/*
     
    751797#ifdef HAVE_TLS
    752798  TCR *tcr = &current_tcr;
    753 #else
     799#else /* no TLS */
    754800  TCR *tcr = allocate_tcr();
    755 #endif
    756 
    757 #ifdef X8664
     801#ifdef X8632
     802  setup_tcr_extra_segment(tcr);
     803#endif
     804#endif
     805
     806#ifdef X86
    758807  setup_tcr_extra_segment(tcr);
    759808  tcr->linear = tcr;
     809#ifdef X8632
     810  tcr->node_regs_mask = X8632_DEFAULT_NODE_REGS_MASK;
     811#endif
    760812#endif
    761813
     
    857909    dequeue_tcr(tcr);
    858910#endif
     911#ifdef DARWIN
     912#ifdef X8632
     913    free_tcr_extra_segment(tcr);
     914#endif
     915#endif
    859916    UNLOCK(lisp_global(TCR_AREA_LOCK),tcr);
    860917    if (termination_semaphore) {
     
    12581315#define NSAVEREGS 4
    12591316#endif
     1317#ifdef X8632
     1318#define NSAVEREGS 0
     1319#endif
    12601320    for (i = 0; i < NSAVEREGS; i++) {
    12611321      *(--current->save_vsp) = 0;
Note: See TracChangeset for help on using the changeset viewer.