From 88d594a3d52cb5938521619bca0def8e5b040cf0 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 24 May 1995 21:39:42 +0000 Subject: Fully tested on all in-house targets --- cpukit/score/cpu/hppa1.1/cpu.c | 2 +- cpukit/score/cpu/i386/asm.h | 2 +- cpukit/score/cpu/i386/rtems/asm.h | 2 +- cpukit/score/cpu/i960/asm.h | 2 +- cpukit/score/cpu/m68k/asm.h | 2 +- cpukit/score/cpu/m68k/rtems/asm.h | 2 +- cpukit/score/cpu/no_cpu/asm.h | 2 +- cpukit/score/cpu/no_cpu/rtems/asm.h | 2 +- cpukit/score/cpu/unix/cpu.c | 25 +++++++++++++++++-------- 9 files changed, 25 insertions(+), 16 deletions(-) (limited to 'cpukit/score/cpu') diff --git a/cpukit/score/cpu/hppa1.1/cpu.c b/cpukit/score/cpu/hppa1.1/cpu.c index b69a172b4e..027ed07333 100644 --- a/cpukit/score/cpu/hppa1.1/cpu.c +++ b/cpukit/score/cpu/hppa1.1/cpu.c @@ -14,7 +14,7 @@ * Division Incorporated makes no representations about the * suitability of this software for any purpose. * - * $Id$ + * cpu.c,v 1.2 1995/05/09 20:11:35 joel Exp */ #include diff --git a/cpukit/score/cpu/i386/asm.h b/cpukit/score/cpu/i386/asm.h index f123defcd9..16cf6c3235 100644 --- a/cpukit/score/cpu/i386/asm.h +++ b/cpukit/score/cpu/i386/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include +#include /* * Recent versions of GNU cpp define variables which indicate the diff --git a/cpukit/score/cpu/i386/rtems/asm.h b/cpukit/score/cpu/i386/rtems/asm.h index f123defcd9..16cf6c3235 100644 --- a/cpukit/score/cpu/i386/rtems/asm.h +++ b/cpukit/score/cpu/i386/rtems/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include +#include /* * Recent versions of GNU cpp define variables which indicate the diff --git a/cpukit/score/cpu/i960/asm.h b/cpukit/score/cpu/i960/asm.h index 1c40601473..e8fc986402 100644 --- a/cpukit/score/cpu/i960/asm.h +++ b/cpukit/score/cpu/i960/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include +#include /* * Recent versions of GNU cpp define variables which indicate the diff --git a/cpukit/score/cpu/m68k/asm.h b/cpukit/score/cpu/m68k/asm.h index 068c58058c..58bb04bdf9 100644 --- a/cpukit/score/cpu/m68k/asm.h +++ b/cpukit/score/cpu/m68k/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include +#include /* * Recent versions of GNU cpp define variables which indicate the diff --git a/cpukit/score/cpu/m68k/rtems/asm.h b/cpukit/score/cpu/m68k/rtems/asm.h index 068c58058c..58bb04bdf9 100644 --- a/cpukit/score/cpu/m68k/rtems/asm.h +++ b/cpukit/score/cpu/m68k/rtems/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include +#include /* * Recent versions of GNU cpp define variables which indicate the diff --git a/cpukit/score/cpu/no_cpu/asm.h b/cpukit/score/cpu/no_cpu/asm.h index 69b1f0f825..97464d5b3a 100644 --- a/cpukit/score/cpu/no_cpu/asm.h +++ b/cpukit/score/cpu/no_cpu/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include +#include /* * Recent versions of GNU cpp define variables which indicate the diff --git a/cpukit/score/cpu/no_cpu/rtems/asm.h b/cpukit/score/cpu/no_cpu/rtems/asm.h index 69b1f0f825..97464d5b3a 100644 --- a/cpukit/score/cpu/no_cpu/rtems/asm.h +++ b/cpukit/score/cpu/no_cpu/rtems/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include +#include /* * Recent versions of GNU cpp define variables which indicate the diff --git a/cpukit/score/cpu/unix/cpu.c b/cpukit/score/cpu/unix/cpu.c index ed94953d58..68397a4e29 100644 --- a/cpukit/score/cpu/unix/cpu.c +++ b/cpukit/score/cpu/unix/cpu.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -225,18 +224,28 @@ void _CPU_Context_Initialize( unsigned32 *_stack_base, unsigned32 _size, unsigned32 _new_level, - proc_ptr *_entry_point + void *_entry_point ) { unsigned32 *addr; unsigned32 jmp_addr; - unsigned32 _stack; + unsigned32 _stack_low; /* lowest "stack aligned" address */ + unsigned32 _stack_high; /* highest "stack aligned" address */ unsigned32 _the_size; jmp_addr = (unsigned32) _entry_point; - _stack = ((unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT); - _stack &= ~(CPU_STACK_ALIGNMENT - 1); + /* + * On CPUs with stacks which grow down, we build the stack + * based on the _stack_high address. On CPUs with stacks which + * grow up, we build the stack based on the _stack_low address. + */ + + _stack_low = ((unsigned32)(_stack_base) + CPU_STACK_ALIGNMENT); + _stack_low &= ~(CPU_STACK_ALIGNMENT - 1); + + _stack_high = ((unsigned32)(_stack_base) + _size); + _stack_high &= ~(CPU_STACK_ALIGNMENT - 1); _the_size = _size & ~(CPU_STACK_ALIGNMENT - 1); @@ -250,7 +259,7 @@ void _CPU_Context_Initialize( #if defined(hppa1_1) *(addr + RP_OFF) = jmp_addr; - *(addr + SP_OFF) = (unsigned32)(_stack + CPU_FRAME_SIZE); + *(addr + SP_OFF) = (unsigned32)(_stack_low + CPU_FRAME_SIZE); /* * See if we are using shared libraries by checking @@ -274,8 +283,8 @@ void _CPU_Context_Initialize( asm ("ta 0x03"); /* flush registers */ *(addr + RP_OFF) = jmp_addr + ADDR_ADJ_OFFSET; - *(addr + SP_OFF) = (unsigned32)(_stack +_the_size - CPU_FRAME_SIZE); - *(addr + FP_OFF) = (unsigned32)(_stack +_the_size); + *(addr + SP_OFF) = (unsigned32)(_stack_high - CPU_FRAME_SIZE); + *(addr + FP_OFF) = (unsigned32)(_stack_high); #else #error "UNKNOWN CPU!!!" #endif -- cgit v1.2.3