Changeset cc4c1fe4 in rtems


Ignore:
Timestamp:
04/22/96 16:44:54 (27 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
a155b3c
Parents:
96981e3a
Message:

added stack allocation fields to the cpu table

updates from Tony Bennett. Most were to insure all variables were properly
initialized and to correct the stray signal number reporting.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/cpu/unix/cpu.c

    r96981e3a rcc4c1fe4  
    4747#include <sys/shm.h>
    4848#include <sys/sem.h>
     49#include <string.h>   /* memset */
    4950
    5051#ifndef SA_RESTART
     
    181182     * HACK - set the _SYSTEM_ID to 0x20c so that setjmp/longjmp
    182183     * will handle the full 32 floating point registers.
    183      *
    184      *  NOTE:  Is this a bug in HPUX9?
    185184     */
    186185
     
    195194   *  get default values to use in _CPU_Context_Initialize()
    196195   */
     196
     197 
     198  (void) memset(
     199    &_CPU_Context_Default_with_ISRs_enabled,
     200    0,
     201    sizeof(Context_Control)
     202  );
     203  (void) memset(
     204    &_CPU_Context_Default_with_ISRs_disabled,
     205    0,
     206    sizeof(Context_Control)
     207  );
    197208
    198209  _CPU_ISR_Set_level( 0 );
     
    383394   */
    384395
    385   _stack_low = ((unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT);
     396  _stack_low = (unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT - 1;
    386397  _stack_low &= ~(CPU_STACK_ALIGNMENT - 1);
    387398
    388   _stack_high = ((unsigned32)(_stack_base) + _size);
     399  _stack_high = (unsigned32)(_stack_base) + _size;
    389400  _stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
    390401
    391   _the_size = _size & ~(CPU_STACK_ALIGNMENT - 1);
     402  if (_stack_high > _stack_low)
     403    _the_size = _stack_high - _stack_low;
     404  else
     405    _the_size = _stack_low - _stack_high;
    392406
    393407  /*
     
    400414    source = &_CPU_Context_Default_with_ISRs_disabled;
    401415     
    402   memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
     416  memcpy(
     417    _the_context,
     418    source,
     419    sizeof(Context_Control)                /* sizeof(jmp_buf)); */
     420  );
    403421
    404422  addr = (unsigned32 *)_the_context;
     
    412430   * bit 30 in 24 off of newp. If bit 30 is set then
    413431   * we are using shared libraries and the jump address
    414    * is at what 24 off of newp points to so shove that
    415    * into 24 off of newp instead.
     432   * points to the pointer, so we put that into rp instead.
    416433   */
    417434
    418435  if (jmp_addr & 0x40000000) {
    419436    jmp_addr &= 0xfffffffc;
    420      *(addr + RP_OFF) = (unsigned32)*(unsigned32 *)jmp_addr;
     437     *(addr + RP_OFF) = *(unsigned32 *)jmp_addr;
    421438  }
    422439#elif defined(sparc)
     
    651668      default:
    652669      {
    653           /*
    654            *  We avoid using the stdio section of the library.
    655            *  The following is generally safe.
    656            */
    657  
    658           buffer[ 0 ] = (sig_num >> 4) + 0x30;
    659           buffer[ 1 ] = (sig_num & 0xf) + 0x30;
    660           buffer[ 2 ] = '\n';
    661  
    662           write( 2, "Stray signal 0x", 12 );
    663           write( 2, buffer, 3 );
     670        /*
     671         *  We avoid using the stdio section of the library.
     672         *  The following is generally safe
     673         */
     674 
     675        int digit;
     676        int number = sig_num;
     677        int len = 0;
     678
     679        digit = number / 100;
     680        number %= 100;
     681        if (digit) buffer[len++] = '0' + digit;
     682
     683        digit = number / 10;
     684        number %= 10;
     685        if (digit || len) buffer[len++] = '0' + digit;
     686
     687        digit = number;
     688        buffer[len++] = '0' + digit;
     689 
     690        buffer[ len++ ] = '\n';
     691 
     692        write( 2, "Stray signal ", 13 );
     693        write( 2, buffer, len );
     694
    664695      }
    665696  }
     
    683714      case SIGSEGV:
    684715      case SIGTERM:
    685           _CPU_Fatal_error(0x100 + sig_num);
     716        _CPU_Fatal_error(0x100 + sig_num);
    686717  }
    687718}
     
    742773   */
    743774 
     775  (void) memset(&act, 0, sizeof(act));
    744776  act.sa_handler = SIG_IGN;
    745 
     777 
    746778  sigaction(SIGALRM, &act, 0);
    747779 
    748   new.it_value.tv_sec = 0;
    749   new.it_value.tv_usec = 0;
    750  
     780  (void) memset(&new, 0, sizeof(new));
    751781  setitimer(ITIMER_REAL, &new, 0);
    752782}
  • c/src/exec/score/cpu/unix/cpu.h

    r96981e3a rcc4c1fe4  
    442442 *  Doing it this way avoids conflicts between the native stuff and the
    443443 *  RTEMS stuff.
    444  */
     444 *
     445 *  NOTE:
     446 *      hpux9 setjmp is optimized for the case where the setjmp buffer
     447 *      is 8 byte aligned.  In a RISC world, this seems likely to enable
     448 *      8 byte copies, especially for the float registers.
     449 *      So we always align them on 8 byte boundaries.
     450 */
     451
     452#ifdef __GNUC__
     453#define CONTEXT_STRUCTURE_ALIGNMENT          __attribute__ ((aligned (8)))
     454#else
     455#define CONTEXT_STRUCTURE_ALIGNMENT
     456#endif
     457
    445458typedef struct {
    446   char      Area[ CPU_CONTEXT_SIZE_IN_BYTES ];
     459  char      Area[ CPU_CONTEXT_SIZE_IN_BYTES ] CONTEXT_STRUCTURE_ALIGNMENT;
    447460} Context_Control;
    448461
     
    456469/*
    457470 *  The following table contains the information required to configure
    458  *  the XXX processor specific parameters.
    459  *
    460  *  NOTE: The interrupt_stack_size field is required if
    461  *        CPU_ALLOCATE_INTERRUPT_STACK is defined as TRUE.
    462  *
    463  *        The pretasking_hook, predriver_hook, and postdriver_hook,
    464  *        and the do_zero_of_workspace fields are required on ALL CPUs.
     471 *  the UNIX Simulator specific parameters.
    465472 */
    466473
     
    473480  unsigned32   interrupt_stack_size;
    474481  unsigned32   extra_mpci_receive_server_stack;
     482  void *     (*stack_allocate_hook)( unsigned32 );
     483  void       (*stack_free_hook)( void* );
     484  /* end of required fields */
    475485}   rtems_cpu_table;
    476486
  • cpukit/score/cpu/unix/cpu.c

    r96981e3a rcc4c1fe4  
    4747#include <sys/shm.h>
    4848#include <sys/sem.h>
     49#include <string.h>   /* memset */
    4950
    5051#ifndef SA_RESTART
     
    181182     * HACK - set the _SYSTEM_ID to 0x20c so that setjmp/longjmp
    182183     * will handle the full 32 floating point registers.
    183      *
    184      *  NOTE:  Is this a bug in HPUX9?
    185184     */
    186185
     
    195194   *  get default values to use in _CPU_Context_Initialize()
    196195   */
     196
     197 
     198  (void) memset(
     199    &_CPU_Context_Default_with_ISRs_enabled,
     200    0,
     201    sizeof(Context_Control)
     202  );
     203  (void) memset(
     204    &_CPU_Context_Default_with_ISRs_disabled,
     205    0,
     206    sizeof(Context_Control)
     207  );
    197208
    198209  _CPU_ISR_Set_level( 0 );
     
    383394   */
    384395
    385   _stack_low = ((unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT);
     396  _stack_low = (unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT - 1;
    386397  _stack_low &= ~(CPU_STACK_ALIGNMENT - 1);
    387398
    388   _stack_high = ((unsigned32)(_stack_base) + _size);
     399  _stack_high = (unsigned32)(_stack_base) + _size;
    389400  _stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
    390401
    391   _the_size = _size & ~(CPU_STACK_ALIGNMENT - 1);
     402  if (_stack_high > _stack_low)
     403    _the_size = _stack_high - _stack_low;
     404  else
     405    _the_size = _stack_low - _stack_high;
    392406
    393407  /*
     
    400414    source = &_CPU_Context_Default_with_ISRs_disabled;
    401415     
    402   memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
     416  memcpy(
     417    _the_context,
     418    source,
     419    sizeof(Context_Control)                /* sizeof(jmp_buf)); */
     420  );
    403421
    404422  addr = (unsigned32 *)_the_context;
     
    412430   * bit 30 in 24 off of newp. If bit 30 is set then
    413431   * we are using shared libraries and the jump address
    414    * is at what 24 off of newp points to so shove that
    415    * into 24 off of newp instead.
     432   * points to the pointer, so we put that into rp instead.
    416433   */
    417434
    418435  if (jmp_addr & 0x40000000) {
    419436    jmp_addr &= 0xfffffffc;
    420      *(addr + RP_OFF) = (unsigned32)*(unsigned32 *)jmp_addr;
     437     *(addr + RP_OFF) = *(unsigned32 *)jmp_addr;
    421438  }
    422439#elif defined(sparc)
     
    651668      default:
    652669      {
    653           /*
    654            *  We avoid using the stdio section of the library.
    655            *  The following is generally safe.
    656            */
    657  
    658           buffer[ 0 ] = (sig_num >> 4) + 0x30;
    659           buffer[ 1 ] = (sig_num & 0xf) + 0x30;
    660           buffer[ 2 ] = '\n';
    661  
    662           write( 2, "Stray signal 0x", 12 );
    663           write( 2, buffer, 3 );
     670        /*
     671         *  We avoid using the stdio section of the library.
     672         *  The following is generally safe
     673         */
     674 
     675        int digit;
     676        int number = sig_num;
     677        int len = 0;
     678
     679        digit = number / 100;
     680        number %= 100;
     681        if (digit) buffer[len++] = '0' + digit;
     682
     683        digit = number / 10;
     684        number %= 10;
     685        if (digit || len) buffer[len++] = '0' + digit;
     686
     687        digit = number;
     688        buffer[len++] = '0' + digit;
     689 
     690        buffer[ len++ ] = '\n';
     691 
     692        write( 2, "Stray signal ", 13 );
     693        write( 2, buffer, len );
     694
    664695      }
    665696  }
     
    683714      case SIGSEGV:
    684715      case SIGTERM:
    685           _CPU_Fatal_error(0x100 + sig_num);
     716        _CPU_Fatal_error(0x100 + sig_num);
    686717  }
    687718}
     
    742773   */
    743774 
     775  (void) memset(&act, 0, sizeof(act));
    744776  act.sa_handler = SIG_IGN;
    745 
     777 
    746778  sigaction(SIGALRM, &act, 0);
    747779 
    748   new.it_value.tv_sec = 0;
    749   new.it_value.tv_usec = 0;
    750  
     780  (void) memset(&new, 0, sizeof(new));
    751781  setitimer(ITIMER_REAL, &new, 0);
    752782}
Note: See TracChangeset for help on using the changeset viewer.