mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-07 16:13:07 +00:00
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.
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <sys/sem.h>
|
#include <sys/sem.h>
|
||||||
|
#include <string.h> /* memset */
|
||||||
|
|
||||||
#ifndef SA_RESTART
|
#ifndef SA_RESTART
|
||||||
#define SA_RESTART 0
|
#define SA_RESTART 0
|
||||||
@@ -180,8 +181,6 @@ void _CPU_Context_From_CPU_Init()
|
|||||||
/*
|
/*
|
||||||
* HACK - set the _SYSTEM_ID to 0x20c so that setjmp/longjmp
|
* HACK - set the _SYSTEM_ID to 0x20c so that setjmp/longjmp
|
||||||
* will handle the full 32 floating point registers.
|
* will handle the full 32 floating point registers.
|
||||||
*
|
|
||||||
* NOTE: Is this a bug in HPUX9?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -195,6 +194,18 @@ void _CPU_Context_From_CPU_Init()
|
|||||||
* get default values to use in _CPU_Context_Initialize()
|
* get default values to use in _CPU_Context_Initialize()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
(void) memset(
|
||||||
|
&_CPU_Context_Default_with_ISRs_enabled,
|
||||||
|
0,
|
||||||
|
sizeof(Context_Control)
|
||||||
|
);
|
||||||
|
(void) memset(
|
||||||
|
&_CPU_Context_Default_with_ISRs_disabled,
|
||||||
|
0,
|
||||||
|
sizeof(Context_Control)
|
||||||
|
);
|
||||||
|
|
||||||
_CPU_ISR_Set_level( 0 );
|
_CPU_ISR_Set_level( 0 );
|
||||||
_CPU_Context_switch(
|
_CPU_Context_switch(
|
||||||
&_CPU_Context_Default_with_ISRs_enabled,
|
&_CPU_Context_Default_with_ISRs_enabled,
|
||||||
@@ -382,13 +393,16 @@ void _CPU_Context_Initialize(
|
|||||||
* grow up, we build the stack based on the _stack_low address.
|
* grow up, we build the stack based on the _stack_low address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_stack_low = ((unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT);
|
_stack_low = (unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT - 1;
|
||||||
_stack_low &= ~(CPU_STACK_ALIGNMENT - 1);
|
_stack_low &= ~(CPU_STACK_ALIGNMENT - 1);
|
||||||
|
|
||||||
_stack_high = ((unsigned32)(_stack_base) + _size);
|
_stack_high = (unsigned32)(_stack_base) + _size;
|
||||||
_stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
|
_stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
|
||||||
|
|
||||||
_the_size = _size & ~(CPU_STACK_ALIGNMENT - 1);
|
if (_stack_high > _stack_low)
|
||||||
|
_the_size = _stack_high - _stack_low;
|
||||||
|
else
|
||||||
|
_the_size = _stack_low - _stack_high;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Slam our jmp_buf template into the context we are creating
|
* Slam our jmp_buf template into the context we are creating
|
||||||
@@ -399,7 +413,11 @@ void _CPU_Context_Initialize(
|
|||||||
else
|
else
|
||||||
source = &_CPU_Context_Default_with_ISRs_disabled;
|
source = &_CPU_Context_Default_with_ISRs_disabled;
|
||||||
|
|
||||||
memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
|
memcpy(
|
||||||
|
_the_context,
|
||||||
|
source,
|
||||||
|
sizeof(Context_Control) /* sizeof(jmp_buf)); */
|
||||||
|
);
|
||||||
|
|
||||||
addr = (unsigned32 *)_the_context;
|
addr = (unsigned32 *)_the_context;
|
||||||
|
|
||||||
@@ -411,13 +429,12 @@ void _CPU_Context_Initialize(
|
|||||||
* See if we are using shared libraries by checking
|
* See if we are using shared libraries by checking
|
||||||
* bit 30 in 24 off of newp. If bit 30 is set then
|
* bit 30 in 24 off of newp. If bit 30 is set then
|
||||||
* we are using shared libraries and the jump address
|
* we are using shared libraries and the jump address
|
||||||
* is at what 24 off of newp points to so shove that
|
* points to the pointer, so we put that into rp instead.
|
||||||
* into 24 off of newp instead.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (jmp_addr & 0x40000000) {
|
if (jmp_addr & 0x40000000) {
|
||||||
jmp_addr &= 0xfffffffc;
|
jmp_addr &= 0xfffffffc;
|
||||||
*(addr + RP_OFF) = (unsigned32)*(unsigned32 *)jmp_addr;
|
*(addr + RP_OFF) = *(unsigned32 *)jmp_addr;
|
||||||
}
|
}
|
||||||
#elif defined(sparc)
|
#elif defined(sparc)
|
||||||
|
|
||||||
@@ -652,15 +669,29 @@ void _CPU_Stray_signal(int sig_num)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We avoid using the stdio section of the library.
|
* We avoid using the stdio section of the library.
|
||||||
* The following is generally safe.
|
* The following is generally safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
buffer[ 0 ] = (sig_num >> 4) + 0x30;
|
int digit;
|
||||||
buffer[ 1 ] = (sig_num & 0xf) + 0x30;
|
int number = sig_num;
|
||||||
buffer[ 2 ] = '\n';
|
int len = 0;
|
||||||
|
|
||||||
|
digit = number / 100;
|
||||||
|
number %= 100;
|
||||||
|
if (digit) buffer[len++] = '0' + digit;
|
||||||
|
|
||||||
|
digit = number / 10;
|
||||||
|
number %= 10;
|
||||||
|
if (digit || len) buffer[len++] = '0' + digit;
|
||||||
|
|
||||||
|
digit = number;
|
||||||
|
buffer[len++] = '0' + digit;
|
||||||
|
|
||||||
|
buffer[ len++ ] = '\n';
|
||||||
|
|
||||||
|
write( 2, "Stray signal ", 13 );
|
||||||
|
write( 2, buffer, len );
|
||||||
|
|
||||||
write( 2, "Stray signal 0x", 12 );
|
|
||||||
write( 2, buffer, 3 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,13 +772,12 @@ void _CPU_Stop_clock( void )
|
|||||||
* vector.
|
* vector.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
(void) memset(&act, 0, sizeof(act));
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
|
|
||||||
sigaction(SIGALRM, &act, 0);
|
sigaction(SIGALRM, &act, 0);
|
||||||
|
|
||||||
new.it_value.tv_sec = 0;
|
(void) memset(&new, 0, sizeof(new));
|
||||||
new.it_value.tv_usec = 0;
|
|
||||||
|
|
||||||
setitimer(ITIMER_REAL, &new, 0);
|
setitimer(ITIMER_REAL, &new, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -441,9 +441,22 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* Doing it this way avoids conflicts between the native stuff and the
|
* Doing it this way avoids conflicts between the native stuff and the
|
||||||
* RTEMS stuff.
|
* RTEMS stuff.
|
||||||
|
*
|
||||||
|
* NOTE:
|
||||||
|
* hpux9 setjmp is optimized for the case where the setjmp buffer
|
||||||
|
* is 8 byte aligned. In a RISC world, this seems likely to enable
|
||||||
|
* 8 byte copies, especially for the float registers.
|
||||||
|
* So we always align them on 8 byte boundaries.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define CONTEXT_STRUCTURE_ALIGNMENT __attribute__ ((aligned (8)))
|
||||||
|
#else
|
||||||
|
#define CONTEXT_STRUCTURE_ALIGNMENT
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char Area[ CPU_CONTEXT_SIZE_IN_BYTES ];
|
char Area[ CPU_CONTEXT_SIZE_IN_BYTES ] CONTEXT_STRUCTURE_ALIGNMENT;
|
||||||
} Context_Control;
|
} Context_Control;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -455,13 +468,7 @@ typedef struct {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The following table contains the information required to configure
|
* The following table contains the information required to configure
|
||||||
* the XXX processor specific parameters.
|
* the UNIX Simulator specific parameters.
|
||||||
*
|
|
||||||
* NOTE: The interrupt_stack_size field is required if
|
|
||||||
* CPU_ALLOCATE_INTERRUPT_STACK is defined as TRUE.
|
|
||||||
*
|
|
||||||
* The pretasking_hook, predriver_hook, and postdriver_hook,
|
|
||||||
* and the do_zero_of_workspace fields are required on ALL CPUs.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -472,6 +479,9 @@ typedef struct {
|
|||||||
boolean do_zero_of_workspace;
|
boolean do_zero_of_workspace;
|
||||||
unsigned32 interrupt_stack_size;
|
unsigned32 interrupt_stack_size;
|
||||||
unsigned32 extra_mpci_receive_server_stack;
|
unsigned32 extra_mpci_receive_server_stack;
|
||||||
|
void * (*stack_allocate_hook)( unsigned32 );
|
||||||
|
void (*stack_free_hook)( void* );
|
||||||
|
/* end of required fields */
|
||||||
} rtems_cpu_table;
|
} rtems_cpu_table;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <sys/sem.h>
|
#include <sys/sem.h>
|
||||||
|
#include <string.h> /* memset */
|
||||||
|
|
||||||
#ifndef SA_RESTART
|
#ifndef SA_RESTART
|
||||||
#define SA_RESTART 0
|
#define SA_RESTART 0
|
||||||
@@ -180,8 +181,6 @@ void _CPU_Context_From_CPU_Init()
|
|||||||
/*
|
/*
|
||||||
* HACK - set the _SYSTEM_ID to 0x20c so that setjmp/longjmp
|
* HACK - set the _SYSTEM_ID to 0x20c so that setjmp/longjmp
|
||||||
* will handle the full 32 floating point registers.
|
* will handle the full 32 floating point registers.
|
||||||
*
|
|
||||||
* NOTE: Is this a bug in HPUX9?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -195,6 +194,18 @@ void _CPU_Context_From_CPU_Init()
|
|||||||
* get default values to use in _CPU_Context_Initialize()
|
* get default values to use in _CPU_Context_Initialize()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
(void) memset(
|
||||||
|
&_CPU_Context_Default_with_ISRs_enabled,
|
||||||
|
0,
|
||||||
|
sizeof(Context_Control)
|
||||||
|
);
|
||||||
|
(void) memset(
|
||||||
|
&_CPU_Context_Default_with_ISRs_disabled,
|
||||||
|
0,
|
||||||
|
sizeof(Context_Control)
|
||||||
|
);
|
||||||
|
|
||||||
_CPU_ISR_Set_level( 0 );
|
_CPU_ISR_Set_level( 0 );
|
||||||
_CPU_Context_switch(
|
_CPU_Context_switch(
|
||||||
&_CPU_Context_Default_with_ISRs_enabled,
|
&_CPU_Context_Default_with_ISRs_enabled,
|
||||||
@@ -382,13 +393,16 @@ void _CPU_Context_Initialize(
|
|||||||
* grow up, we build the stack based on the _stack_low address.
|
* grow up, we build the stack based on the _stack_low address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_stack_low = ((unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT);
|
_stack_low = (unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT - 1;
|
||||||
_stack_low &= ~(CPU_STACK_ALIGNMENT - 1);
|
_stack_low &= ~(CPU_STACK_ALIGNMENT - 1);
|
||||||
|
|
||||||
_stack_high = ((unsigned32)(_stack_base) + _size);
|
_stack_high = (unsigned32)(_stack_base) + _size;
|
||||||
_stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
|
_stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
|
||||||
|
|
||||||
_the_size = _size & ~(CPU_STACK_ALIGNMENT - 1);
|
if (_stack_high > _stack_low)
|
||||||
|
_the_size = _stack_high - _stack_low;
|
||||||
|
else
|
||||||
|
_the_size = _stack_low - _stack_high;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Slam our jmp_buf template into the context we are creating
|
* Slam our jmp_buf template into the context we are creating
|
||||||
@@ -399,7 +413,11 @@ void _CPU_Context_Initialize(
|
|||||||
else
|
else
|
||||||
source = &_CPU_Context_Default_with_ISRs_disabled;
|
source = &_CPU_Context_Default_with_ISRs_disabled;
|
||||||
|
|
||||||
memcpy(_the_context, source, sizeof(Context_Control) ); /* sizeof(jmp_buf)); */
|
memcpy(
|
||||||
|
_the_context,
|
||||||
|
source,
|
||||||
|
sizeof(Context_Control) /* sizeof(jmp_buf)); */
|
||||||
|
);
|
||||||
|
|
||||||
addr = (unsigned32 *)_the_context;
|
addr = (unsigned32 *)_the_context;
|
||||||
|
|
||||||
@@ -411,13 +429,12 @@ void _CPU_Context_Initialize(
|
|||||||
* See if we are using shared libraries by checking
|
* See if we are using shared libraries by checking
|
||||||
* bit 30 in 24 off of newp. If bit 30 is set then
|
* bit 30 in 24 off of newp. If bit 30 is set then
|
||||||
* we are using shared libraries and the jump address
|
* we are using shared libraries and the jump address
|
||||||
* is at what 24 off of newp points to so shove that
|
* points to the pointer, so we put that into rp instead.
|
||||||
* into 24 off of newp instead.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (jmp_addr & 0x40000000) {
|
if (jmp_addr & 0x40000000) {
|
||||||
jmp_addr &= 0xfffffffc;
|
jmp_addr &= 0xfffffffc;
|
||||||
*(addr + RP_OFF) = (unsigned32)*(unsigned32 *)jmp_addr;
|
*(addr + RP_OFF) = *(unsigned32 *)jmp_addr;
|
||||||
}
|
}
|
||||||
#elif defined(sparc)
|
#elif defined(sparc)
|
||||||
|
|
||||||
@@ -652,15 +669,29 @@ void _CPU_Stray_signal(int sig_num)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We avoid using the stdio section of the library.
|
* We avoid using the stdio section of the library.
|
||||||
* The following is generally safe.
|
* The following is generally safe
|
||||||
*/
|
*/
|
||||||
|
|
||||||
buffer[ 0 ] = (sig_num >> 4) + 0x30;
|
int digit;
|
||||||
buffer[ 1 ] = (sig_num & 0xf) + 0x30;
|
int number = sig_num;
|
||||||
buffer[ 2 ] = '\n';
|
int len = 0;
|
||||||
|
|
||||||
|
digit = number / 100;
|
||||||
|
number %= 100;
|
||||||
|
if (digit) buffer[len++] = '0' + digit;
|
||||||
|
|
||||||
|
digit = number / 10;
|
||||||
|
number %= 10;
|
||||||
|
if (digit || len) buffer[len++] = '0' + digit;
|
||||||
|
|
||||||
|
digit = number;
|
||||||
|
buffer[len++] = '0' + digit;
|
||||||
|
|
||||||
|
buffer[ len++ ] = '\n';
|
||||||
|
|
||||||
|
write( 2, "Stray signal ", 13 );
|
||||||
|
write( 2, buffer, len );
|
||||||
|
|
||||||
write( 2, "Stray signal 0x", 12 );
|
|
||||||
write( 2, buffer, 3 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,13 +772,12 @@ void _CPU_Stop_clock( void )
|
|||||||
* vector.
|
* vector.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
(void) memset(&act, 0, sizeof(act));
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
|
|
||||||
sigaction(SIGALRM, &act, 0);
|
sigaction(SIGALRM, &act, 0);
|
||||||
|
|
||||||
new.it_value.tv_sec = 0;
|
(void) memset(&new, 0, sizeof(new));
|
||||||
new.it_value.tv_usec = 0;
|
|
||||||
|
|
||||||
setitimer(ITIMER_REAL, &new, 0);
|
setitimer(ITIMER_REAL, &new, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user