/[cmucl]/src/lisp/FreeBSD-os.c
ViewVC logotype

Diff of /src/lisp/FreeBSD-os.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by cshapiro, Tue Mar 18 09:22:55 2008 UTC revision 1.23.2.2 by rtoy, Thu Dec 18 21:50:19 2008 UTC
# Line 48  os_init(void) Line 48  os_init(void)
48  unsigned long *  unsigned long *
49  os_sigcontext_reg(ucontext_t *scp, int index)  os_sigcontext_reg(ucontext_t *scp, int index)
50  {  {
51        __register_t *rv;
52      switch (index) {      switch (index) {
53      case 0:      case 0:
54          return (unsigned long *) &scp->uc_mcontext.mc_eax;          rv = &scp->uc_mcontext.mc_eax;
55            break;
56      case 2:      case 2:
57          return (unsigned long *) &scp->uc_mcontext.mc_ecx;          rv = &scp->uc_mcontext.mc_ecx;
58            break;
59      case 4:      case 4:
60          return (unsigned long *) &scp->uc_mcontext.mc_edx;          rv = &scp->uc_mcontext.mc_edx;
61            break;
62      case 6:      case 6:
63          return (unsigned long *) &scp->uc_mcontext.mc_ebx;          rv = &scp->uc_mcontext.mc_ebx;
64            break;
65      case 8:      case 8:
66          return (unsigned long *) &scp->uc_mcontext.mc_esp;          rv = &scp->uc_mcontext.mc_esp;
67            break;
68      case 10:      case 10:
69          return (unsigned long *) &scp->uc_mcontext.mc_ebp;          rv = &scp->uc_mcontext.mc_ebp;
70            break;
71      case 12:      case 12:
72          return (unsigned long *) &scp->uc_mcontext.mc_esi;          rv = &scp->uc_mcontext.mc_esi;
73            break;
74      case 14:      case 14:
75          return (unsigned long *) &scp->uc_mcontext.mc_edi;          rv = &scp->uc_mcontext.mc_edi;
76            break;
77        default:
78            rv = NULL;
79      }      }
80      return NULL;  
81        /* Pre-cast to (void *), to avoid the compiler warning:
82         * FreeBSD-os.c:72: warning: dereferencing type-punned pointer will break strict-aliasing rules
83         */
84        return (unsigned long *) (void *) rv;
85  }  }
86    
87  unsigned long *  unsigned long *
88  os_sigcontext_pc(ucontext_t *scp)  os_sigcontext_pc(ucontext_t *scp)
89  {  {
90      return (unsigned long *) &scp->uc_mcontext.mc_eip;      return (unsigned long *) (void *) &scp->uc_mcontext.mc_eip;
91  }  }
92    
93  unsigned char *  unsigned char *
# Line 96  os_sigcontext_fpu_reg(ucontext_t *scp, i Line 111  os_sigcontext_fpu_reg(ucontext_t *scp, i
111      return reg;      return reg;
112  }  }
113    
114  unsigned long  unsigned int
115  os_sigcontext_fpu_modes(ucontext_t *scp)  os_sigcontext_fpu_modes(ucontext_t *scp)
116  {  {
117        unsigned int modes;
118    
119      union savefpu *sv = (union savefpu *) scp->uc_mcontext.mc_fpstate;      union savefpu *sv = (union savefpu *) scp->uc_mcontext.mc_fpstate;
     unsigned long modes;  
120      int fpformat = scp->uc_mcontext.mc_fpformat;      int fpformat = scp->uc_mcontext.mc_fpformat;
121      unsigned short cw, sw;      struct env87 *env_87 = &sv->sv_87.sv_env;
122        struct envxmm *env_xmm = &sv->sv_xmm.sv_env;
123        u_int16_t cw;
124        u_int16_t sw;
125    
126      if (fpformat == _MC_FPFMT_XMM) {      if (fpformat == _MC_FPFMT_XMM) {
127          cw = sv->sv_xmm.sv_env.en_cw;          cw = env_xmm->en_cw;
128          sw = sv->sv_xmm.sv_env.en_sw;          sw = env_xmm->en_sw;
129      } else if (fpformat == _MC_FPFMT_387) {      } else if (fpformat == _MC_FPFMT_387) {
130          cw = sv->sv_87.sv_env.en_cw & 0xffff;          cw = env_87->en_cw & 0xffff;
131          sw = sv->sv_87.sv_env.en_sw & 0xffff;          sw = env_87->en_sw & 0xffff;
132      } else {  /* _MC_FPFMT_NODEV */      } else {  /* _MC_FPFMT_NODEV */
133          cw = 0;          cw = 0;
134          sw = 0x3f;          sw = 0x3f;
135      }      }
136      modes = (sw & 0xff) << 16 | cw;  
137      modes ^= 0x3f;      modes = ((cw & 0x3f) << 7) | (sw & 0x3f);
138    
139    #ifdef FEATURE_SSE2
140        if (arch_support_sse2()) {
141            u_int32_t mxcsr = env_xmm->en_mxcsr;
142            DPRINTF(0, (stderr, "SSE2 modes = %08x\n", (int) mxcsr));
143            modes |= mxcsr;
144        }
145    #endif
146        modes ^= (0x3f << 7);
147      return modes;      return modes;
148  }  }
149    
# Line 201  boolean valid_addr(os_vm_address_t addr) Line 229  boolean valid_addr(os_vm_address_t addr)
229  static void  static void
230  sigbus_handler(int signal, siginfo_t *info, ucontext_t *context)  sigbus_handler(int signal, siginfo_t *info, ucontext_t *context)
231  {  {
     int page_index;  
   
232  #ifdef RED_ZONE_HIT  #ifdef RED_ZONE_HIT
233      if (os_control_stack_overflow(info->si_addr, context))      if (os_control_stack_overflow(info->si_addr, context))
234          return;          return;
# Line 210  sigbus_handler(int signal, siginfo_t *in Line 236  sigbus_handler(int signal, siginfo_t *in
236    
237  #if defined GENCGC  #if defined GENCGC
238      if (info->si_code == PROTECTION_VIOLATION_CODE) {      if (info->si_code == PROTECTION_VIOLATION_CODE) {
239          page_index = find_page_index(info->si_addr);          if (gc_write_barrier(info->si_addr)) {
   
         /* Check if the fault is within the dynamic space. */  
         if (page_index != -1) {  
             /* Un-protect the page */  
   
             /* The page should have been marked write protected */  
             if (!PAGE_WRITE_PROTECTED(page_index))  
                 fprintf(stderr,  
                         "*** Sigbus in page not marked as write protected\n");  
   
             os_protect(page_address(page_index), 4096, OS_VM_PROT_ALL);  
             page_table[page_index].flags &= ~PAGE_WRITE_PROTECTED_MASK;  
             page_table[page_index].flags |= PAGE_WRITE_PROTECT_CLEARED_MASK;  
   
240              return;              return;
241          }          }
242      }      }
# Line 309  restore_fpu(ucontext_t *scp) Line 321  restore_fpu(ucontext_t *scp)
321  {  {
322      union savefpu *sv = (union savefpu *) scp->uc_mcontext.mc_fpstate;      union savefpu *sv = (union savefpu *) scp->uc_mcontext.mc_fpstate;
323      int fpformat = scp->uc_mcontext.mc_fpformat;      int fpformat = scp->uc_mcontext.mc_fpformat;
324      unsigned short cw;      struct env87 *env_87 = &sv->sv_87.sv_env;
325        struct envxmm *env_xmm = &sv->sv_xmm.sv_env;
326        u_int16_t cw;
327    
328      if (fpformat == _MC_FPFMT_XMM) {      if (fpformat == _MC_FPFMT_XMM) {
329          cw = sv->sv_xmm.sv_env.en_cw;          cw = env_xmm->en_cw;
330      } else if (fpformat == _MC_FPFMT_387) {      } else if (fpformat == _MC_FPFMT_387) {
331          cw = sv->sv_87.sv_env.en_cw & 0xffff;          cw = env_87->en_cw & 0xffff;
332      } else {  /* _MC_FPFMT_NODEV */      } else {  /* _MC_FPFMT_NODEV */
333          return;          return;
334      }      }
335        DPRINTF(0, (stderr, "restore_fpu:  cw = %08x\n", (int) cw));
336      __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw));      __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw));
337    #ifdef FEATURE_SSE2
338        if (arch_support_sse2()) {
339            u_int32_t mxcsr = env_xmm->en_mxcsr;
340            DPRINTF(0, (stderr, "restore_fpu:  mxcsr (raw) = %04x\n", mxcsr));
341            __asm__ __volatile__ ("ldmxcsr %0" :: "m" (*&mxcsr));
342        }
343    #endif
344  }  }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.23.2.2

  ViewVC Help
Powered by ViewVC 1.1.5