Changeset d196e48 in rtems for c/src/exec/score/cpu
- Timestamp:
- 05/23/96 15:34:54 (27 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 859f17ce
- Parents:
- 2328475
- Location:
- c/src/exec/score/cpu/unix
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/score/cpu/unix/cpu.c
r2328475 rd196e48 56 56 typedef struct { 57 57 jmp_buf regs; 58 sigset_tisr_level;58 unsigned32 isr_level; 59 59 } Context_Control_overlay; 60 60 … … 63 63 void _CPU_ISR_Handler(int); 64 64 65 s igset_t _CPU_Signal_mask;66 Context_Control_CPU_Context_Default_with_ISRs_enabled;67 Context_Control_CPU_Context_Default_with_ISRs_disabled;65 static sigset_t _CPU_Signal_mask; 66 static Context_Control_overlay _CPU_Context_Default_with_ISRs_enabled; 67 static Context_Control_overlay _CPU_Context_Default_with_ISRs_disabled; 68 68 69 69 /* … … 93 93 /* 94 94 * Block all the signals except SIGTRAP for the debugger 95 * and SIGABRT for fatal errors.95 * and fatal error signals. 96 96 */ 97 97 … … 101 101 (void) sigdelset(&_CPU_Signal_mask, SIGIOT); 102 102 (void) sigdelset(&_CPU_Signal_mask, SIGCONT); 103 (void) sigdelset(&_CPU_Signal_mask, SIGSEGV); 104 (void) sigdelset(&_CPU_Signal_mask, SIGBUS); 105 (void) sigdelset(&_CPU_Signal_mask, SIGFPE); 103 106 104 107 _CPU_ISR_Enable(1); … … 121 124 struct sigaction act; 122 125 sigset_t mask; 123 126 124 127 /* mark them all active except for TraceTrap and Abort */ 125 126 sigfillset(&mask); 127 sigdelset(&mask, SIGTRAP); 128 sigdelset(&mask, SIGABRT); 129 sigdelset(&mask, SIGIOT); 130 sigdelset(&mask, SIGCONT); 128 129 mask = _CPU_Signal_mask; 131 130 sigprocmask(SIG_UNBLOCK, &mask, 0); 132 131 133 132 act.sa_handler = _CPU_ISR_Handler; 134 133 act.sa_mask = mask; 135 134 act.sa_flags = SA_RESTART; 136 135 137 136 sigaction(SIGHUP, &act, 0); 138 137 sigaction(SIGINT, &act, 0); … … 168 167 sigaction(SIGLOST, &act, 0); 169 168 #endif 170 171 169 } 172 170 … … 210 208 _CPU_ISR_Set_level( 0 ); 211 209 _CPU_Context_switch( 212 &_CPU_Context_Default_with_ISRs_enabled,213 &_CPU_Context_Default_with_ISRs_enabled210 (Context_Control *) &_CPU_Context_Default_with_ISRs_enabled, 211 (Context_Control *) &_CPU_Context_Default_with_ISRs_enabled 214 212 ); 215 213 216 214 _CPU_ISR_Set_level( 1 ); 217 215 _CPU_Context_switch( 218 &_CPU_Context_Default_with_ISRs_disabled,219 &_CPU_Context_Default_with_ISRs_disabled216 (Context_Control *) &_CPU_Context_Default_with_ISRs_disabled, 217 (Context_Control *) &_CPU_Context_Default_with_ISRs_disabled 220 218 ); 221 219 } … … 226 224 */ 227 225 228 sigset_t GET_old_mask;229 230 226 unsigned32 _CPU_ISR_Get_level( void ) 231 227 { 232 /* sigset_t old_mask; */ 233 unsigned32 old_level; 234 235 sigprocmask(0, 0, &GET_old_mask); 236 237 if (memcmp((void *)&posix_empty_mask, (void *)&GET_old_mask, sizeof(sigset_t))) 238 old_level = 1; 239 else 240 old_level = 0; 241 242 return old_level; 228 sigset_t old_mask; 229 230 sigprocmask(SIG_BLOCK, 0, &old_mask); 231 232 if (memcmp((void *)&posix_empty_mask, (void *)&old_mask, sizeof(sigset_t))) 233 return 1; 234 235 return 0; 243 236 } 244 237 … … 362 355 void _CPU_Thread_Idle_body( void ) 363 356 { 364 while (1) 357 while (1) { 358 #ifdef RTEMS_DEBUG 359 /* interrupts had better be enabled at this point! */ 360 if (_CPU_ISR_Get_level() != 0) 361 abort(); 362 #endif 365 363 pause(); 364 } 365 366 366 } 367 367 … … 380 380 ) 381 381 { 382 void *source;383 382 unsigned32 *addr; 384 383 unsigned32 jmp_addr; … … 411 410 412 411 if ( _new_level == 0 ) 413 source = &_CPU_Context_Default_with_ISRs_enabled; 412 *_the_context = *(Context_Control *) 413 &_CPU_Context_Default_with_ISRs_enabled; 414 414 else 415 source = &_CPU_Context_Default_with_ISRs_disabled; 415 *_the_context = *(Context_Control *) 416 &_CPU_Context_Default_with_ISRs_disabled; 416 417 417 memcpy(418 _the_context,419 source,420 sizeof(Context_Control) /* sizeof(jmp_buf)); */421 );422 423 418 addr = (unsigned32 *)_the_context; 424 419 … … 493 488 Context_Control_overlay *nextp = (Context_Control_overlay *)next; 494 489 495 sigprocmask( SIG_SETMASK, &nextp->isr_level, 0);490 _CPU_ISR_Enable(nextp->isr_level); 496 491 longjmp( nextp->regs, 0 ); 497 492 } … … 501 496 * _CPU_Context_switch 502 497 */ 498 499 static void do_jump( 500 Context_Control_overlay *currentp, 501 Context_Control_overlay *nextp 502 ); 503 503 504 504 void _CPU_Context_switch( … … 509 509 Context_Control_overlay *currentp = (Context_Control_overlay *)current; 510 510 Context_Control_overlay *nextp = (Context_Control_overlay *)next; 511 511 #if 0 512 512 int status; 513 514 /* 515 * Switch levels in one operation 516 */ 517 518 status = sigprocmask( SIG_SETMASK, &nextp->isr_level, ¤tp->isr_level ); 519 if ( status ) 520 _Internal_error_Occurred( 521 INTERNAL_ERROR_CORE, 522 TRUE, 523 status 524 ); 525 526 if (setjmp(currentp->regs) == 0) { /* Save the current context */ 527 longjmp(nextp->regs, 0); /* Switch to the new context */ 528 if ( status ) 529 _Internal_error_Occurred( 513 #endif 514 515 currentp->isr_level = _CPU_ISR_Disable_support(); 516 517 do_jump( currentp, nextp ); 518 519 #if 0 520 if (sigsetjmp(currentp->regs, 1) == 0) { /* Save the current context */ 521 siglongjmp(nextp->regs, 0); /* Switch to the new context */ 522 _Internal_error_Occurred( 530 523 INTERNAL_ERROR_CORE, 531 524 TRUE, … … 533 526 ); 534 527 } 535 536 } 537 528 #endif 529 530 #ifdef RTEMS_DEBUG 531 if (_CPU_ISR_Get_level() == 0) 532 abort(); 533 #endif 534 535 _CPU_ISR_Enable(currentp->isr_level); 536 } 537 538 static void do_jump( 539 Context_Control_overlay *currentp, 540 Context_Control_overlay *nextp 541 ) 542 { 543 int status; 544 545 if (setjmp(currentp->regs) == 0) { /* Save the current context */ 546 longjmp(nextp->regs, 0); /* Switch to the new context */ 547 _Internal_error_Occurred( 548 INTERNAL_ERROR_CORE, 549 TRUE, 550 status 551 ); 552 } 553 } 554 538 555 /*PAGE 539 556 * … … 715 732 case SIGSEGV: 716 733 case SIGTERM: 734 case SIGIOT: 717 735 _CPU_Fatal_error(0x100 + sig_num); 718 736 } -
c/src/exec/score/cpu/unix/cpu.h
r2328475 rd196e48 437 437 * This is really just the area for the following fields. 438 438 * 439 * jmp_buf regs;440 * sigset_tisr_level;439 * jmp_buf regs; 440 * unsigned32 isr_level; 441 441 * 442 442 * Doing it this way avoids conflicts between the native stuff and the
Note: See TracChangeset
for help on using the changeset viewer.