Ignore:
Timestamp:
Oct 14, 2008, 6:30:00 PM (13 years ago)
Author:
gz
Message:

Merge/bootstrap assorted low level stuff from trunk - kernel, syscall stuff, lowmem-bias, formatting tweaks, a few bug fixes included

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/lisp-kernel/thread_manager.c

    r10944 r11089  
    104104    if (io_pending) {
    105105      pending_io * pending = (pending_io *) (target->foreign_exception_status);
    106       if (pCancelIoEx) {
    107         pCancelIoEx(pending->h, pending->o);
     106      if (pending) {
     107        if (pCancelIoEx) {
     108          pCancelIoEx(pending->h, pending->o);
     109        } else {
     110          CancelIo(pending->h);
     111        }
    108112      } else {
    109         CancelIo(pending->h);
     113        QueueUserAPC(nullAPC, hthread, 0);
    110114      }
    111     } else {
    112       QueueUserAPC(nullAPC, hthread, 0);
    113115    }
    114116
     
    132134    *(((LispObj *)icontext)-1) = (LispObj)raise_thread_interrupt;
    133135#else
    134 #warning need interrupt setup for win32
    135 #endif
     136    {
     137      LispObj *p = (LispObj *)icontext;
     138      p -= 4;
     139      p[0] = SIGNAL_FOR_PROCESS_INTERRUPT;
     140      p[1] = 0;
     141      p[2] = (DWORD)icontext;
     142      *(--p) = (LispObj)raise_thread_interrupt;;
     143      xpGPR(pcontext,Isp) = (DWORD)p;
     144#ifdef WIN32_ES_HACK
     145      pcontext->SegEs = pcontext->SegDs;
     146#endif
     147    }
     148#endif
     149    pcontext->EFlags &= ~0x400;  /* clear direction flag */
    136150    xpPC(pcontext) = (LispObj)interrupt_handler;
    137151    SetThreadContext(hthread,pcontext);
     
    659673  void *signal = new_semaphore(0);
    660674#endif
    661 
    662675  if (p) {
    663676    m = (RECURSIVE_LOCK) ((((natural)p)+cache_block_size-1) & (~(cache_block_size-1)));
     
    846859
    847860#ifdef X8632
     861
    848862#ifdef DARWIN
    849863#include <architecture/i386/table.h>
     
    963977
    964978  pthread_mutex_lock(&ldt_lock);
    965   /* load %fs with null segement selector */
     979  /* load %fs with null segment selector */
    966980  __asm__ volatile ("mov %0,%%fs" : : "r"(0));
    967981  tcr->ldt_selector = 0;
     
    10851099}
    10861100
     1101#endif
     1102#ifdef FREEBSD
     1103#include <machine/segments.h>
     1104#include <machine/sysarch.h>
     1105
     1106/* It'd be tempting to use i386_set_fsbase() here, but there doesn't
     1107   seem to be any way to free the GDT entry it creates. */
     1108void
     1109setup_tcr_extra_segment(TCR *tcr)
     1110{
     1111  struct segment_descriptor sd;
     1112  uintptr_t addr = (uintptr_t)tcr;
     1113  unsigned int size = sizeof(*tcr);
     1114  int i;
     1115
     1116  sd.sd_lolimit = (size - 1) & 0xffff;
     1117  sd.sd_hilimit = ((size - 1) >> 16) & 0xf;
     1118  sd.sd_lobase = addr & ((1<<24)-1);
     1119  sd.sd_type = 18;
     1120  sd.sd_dpl = SEL_UPL;
     1121  sd.sd_p = 1;
     1122  sd.sd_def32 = 1;
     1123  sd.sd_gran = 0;
     1124
     1125  i = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)&sd, 1);
     1126
     1127  if (i < 0) {
     1128    perror("i386_set_ldt");
     1129  } else {
     1130    tcr->ldt_selector = LSEL(i,SEL_UPL);
     1131  }
     1132}
     1133
     1134void
     1135free_tcr_extra_segment(TCR *tcr)
     1136{
     1137  int idx = tcr->ldt_selector >> 3;
     1138  /* load %fs with null segment selector */
     1139  __asm__ volatile ("mov %0,%%fs" : : "r"(0));
     1140  if (i386_set_ldt(idx, NULL, 1) < 0)
     1141    perror("i386_set_ldt");
     1142  tcr->ldt_selector = 0;
     1143}
    10871144#endif
    10881145#endif
Note: See TracChangeset for help on using the changeset viewer.