all targets compile .. tony's patches in place

This commit is contained in:
Joel Sherrill
1995-09-29 17:19:16 +00:00
parent 1039ae4125
commit 11290355c9
70 changed files with 632 additions and 321 deletions

View File

@@ -86,7 +86,7 @@ void error(int errn, ...);
#define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */ #define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */
#define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */ #define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */
#define stol(p) strtol(p, (char **) NULL, 0) #define stol(p) strtoul(p, (char **) NULL, 0)
int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm); int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm);
int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm); int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm);

View File

@@ -86,7 +86,7 @@ void error(int errn, ...);
#define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */ #define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */
#define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */ #define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */
#define stol(p) strtol(p, (char **) NULL, 0) #define stol(p) strtoul(p, (char **) NULL, 0)
int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm); int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm);
int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm); int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm);

View File

@@ -39,7 +39,7 @@
* EXAMPLE * EXAMPLE
* if ((fd = open(pathname, O_RDNLY)) < 0) * if ((fd = open(pathname, O_RDNLY)) < 0)
* { * {
* rtems_error(FLOSS_ERROR_ERRNO, "open of '%s' failed", pathname); * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname);
* goto failed; * goto failed;
* } * }
*/ */

View File

@@ -14,9 +14,6 @@
*/ */
#include <rtems.h> #include <rtems.h>
#ifdef RTEMS_LIBC
#include <memory.h>
#endif
#include "libcsupport.h" #include "libcsupport.h"
#ifdef RTEMS_NEWLIB #ifdef RTEMS_NEWLIB
#include <sys/reent.h> #include <sys/reent.h>
@@ -29,22 +26,31 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
/*
* XXX: Do we really need to duplicate these? It appears that they
* only cause typing problems.
*/
#if 0
void *malloc(size_t);
void *calloc(size_t, size_t);
void *realloc(void *, size_t);
void free(void *);
void *sbrk(size_t);
#endif
rtems_id RTEMS_Malloc_Heap; rtems_id RTEMS_Malloc_Heap;
size_t RTEMS_Malloc_Sbrk_amount; size_t RTEMS_Malloc_Sbrk_amount;
#ifdef RTEMS_DEBUG
#define MALLOC_STATS
#endif
#ifdef MALLOC_STATS
#define MSBUMP(f,n) malloc_stats.f += (n)
struct {
unsigned32 space_available; /* current size of malloc area */
unsigned32 malloc_calls; /* # calls to malloc */
unsigned32 free_calls;
unsigned32 realloc_calls;
unsigned32 calloc_calls;
unsigned32 max_depth; /* most ever malloc'd at 1 time */
unsigned64 lifetime_allocated;
unsigned64 lifetime_freed;
} malloc_stats;
#else /* No malloc_stats */
#define MSBUMP(f,n)
#endif
void RTEMS_Malloc_Initialize( void RTEMS_Malloc_Initialize(
void *start, void *start,
size_t length, size_t length,
@@ -78,7 +84,7 @@ void RTEMS_Malloc_Initialize(
u32_address = (u32_address + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); u32_address = (u32_address + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
/* /*
* Adjust the length by whatever we aligned by * adjust the length by whatever we aligned by
*/ */
length -= u32_address - old_address; length -= u32_address - old_address;
@@ -97,12 +103,19 @@ void RTEMS_Malloc_Initialize(
rtems_build_name( 'H', 'E', 'A', 'P' ), rtems_build_name( 'H', 'E', 'A', 'P' ),
starting_address, starting_address,
length, length,
8, /* XXX : use CPU dependent RTEMS constant */ CPU_ALIGNMENT,
RTEMS_DEFAULT_ATTRIBUTES, RTEMS_DEFAULT_ATTRIBUTES,
&RTEMS_Malloc_Heap &RTEMS_Malloc_Heap
); );
if ( status != RTEMS_SUCCESSFUL ) if ( status != RTEMS_SUCCESSFUL )
rtems_fatal_error_occurred( status ); rtems_fatal_error_occurred( status );
#ifdef MALLOC_STATS
/* zero all the stats */
(void) memset(&malloc_stats, 0, sizeof(malloc_stats));
#endif
MSBUMP(space_available, length);
} }
void *malloc( void *malloc(
@@ -115,6 +128,8 @@ void *malloc(
rtems_unsigned32 sbrk_amount; rtems_unsigned32 sbrk_amount;
rtems_status_code status; rtems_status_code status;
MSBUMP(malloc_calls, 1);
if ( !size ) if ( !size )
return (void *) 0; return (void *) 0;
@@ -149,11 +164,6 @@ void *malloc(
if (((rtems_unsigned32)starting_address = sbrk(the_size)) == -1) if (((rtems_unsigned32)starting_address = sbrk(the_size)) == -1)
return (void *) 0; return (void *) 0;
/*
fprintf(stderr, "Extended the C heap starting at 0x%x for %d bytes\n",
(unsigned32)starting_address, the_size);
*/
status = rtems_region_extend( status = rtems_region_extend(
RTEMS_Malloc_Heap, RTEMS_Malloc_Heap,
starting_address, starting_address,
@@ -161,10 +171,12 @@ void *malloc(
); );
if ( status != RTEMS_SUCCESSFUL ) { if ( status != RTEMS_SUCCESSFUL ) {
sbrk(-the_size); sbrk(-the_size);
return(FALSE);
errno = ENOMEM; errno = ENOMEM;
return (void *) 0; return (void *) 0;
} }
MSBUMP(space_available, the_size);
status = rtems_region_get_segment( status = rtems_region_get_segment(
RTEMS_Malloc_Heap, RTEMS_Malloc_Heap,
size, size,
@@ -178,6 +190,17 @@ void *malloc(
} }
} }
#ifdef MALLOC_STATS
if (return_this)
{
unsigned32 current_depth;
MSBUMP(lifetime_allocated, size);
current_depth = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
if (current_depth > malloc_stats.max_depth)
malloc_stats.max_depth = current_depth;
}
#endif
return return_this; return return_this;
} }
@@ -189,6 +212,8 @@ void *calloc(
register char *cptr; register char *cptr;
int length; int length;
MSBUMP(calloc_calls, 1);
length = nelem * elsize; length = nelem * elsize;
cptr = malloc( length ); cptr = malloc( length );
if ( cptr ) if ( cptr )
@@ -206,6 +231,8 @@ void *realloc(
rtems_status_code status; rtems_status_code status;
char *new_area; char *new_area;
MSBUMP(realloc_calls, 1);
if ( !ptr ) if ( !ptr )
return malloc( size ); return malloc( size );
@@ -214,18 +241,18 @@ void *realloc(
return (void *) 0; return (void *) 0;
} }
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size );
if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL;
return (void *) 0;
}
new_area = malloc( size ); new_area = malloc( size );
if ( !new_area ) { if ( !new_area ) {
free( ptr ); free( ptr );
return (void *) 0; return (void *) 0;
} }
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size );
if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL;
return (void *) 0;
}
memcpy( new_area, ptr, (size < old_size) ? size : old_size ); memcpy( new_area, ptr, (size < old_size) ? size : old_size );
free( ptr ); free( ptr );
@@ -239,9 +266,21 @@ void free(
{ {
rtems_status_code status; rtems_status_code status;
MSBUMP(free_calls, 1);
if ( !ptr ) if ( !ptr )
return; return;
#ifdef MALLOC_STATS
{
unsigned32 size;
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &size );
if ( status == RTEMS_SUCCESSFUL ) {
MSBUMP(lifetime_freed, size);
}
}
#endif
status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr ); status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr );
if ( status != RTEMS_SUCCESSFUL ) { if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL; errno = EINVAL;
@@ -249,6 +288,35 @@ void free(
} }
} }
#ifdef MALLOC_STATS
/*
* Dump the malloc statistics
* May be called via atexit() (installable by our bsp) or
* at any time by user
*/
void malloc_dump(void)
{
unsigned32 allocated = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
printf("Malloc stats\n");
printf(" avail:%uk allocated:%uk (%d%%) max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
(unsigned int) malloc_stats.space_available / 1024,
(unsigned int) allocated / 1024,
/* avoid float! */
(allocated * 100) / malloc_stats.space_available,
(unsigned int) malloc_stats.max_depth / 1024,
(malloc_stats.max_depth * 100) / malloc_stats.space_available,
(unsigned long long) malloc_stats.lifetime_allocated / 1024,
(unsigned long long) malloc_stats.lifetime_freed / 1024);
printf(" Call counts: malloc:%d free:%d realloc:%d calloc:%d\n",
malloc_stats.malloc_calls,
malloc_stats.free_calls,
malloc_stats.realloc_calls,
malloc_stats.calloc_calls);
}
#endif
/* /*
* "Reentrant" versions of the above routines implemented above. * "Reentrant" versions of the above routines implemented above.
*/ */

View File

@@ -14,12 +14,13 @@
* Division Incorporated makes no representations about the * Division Incorporated makes no representations about the
* suitability of this software for any purpose. * suitability of this software for any purpose.
* *
* $Id$ * cpu.c,v 1.7 1995/09/19 14:49:35 joel Exp
*/ */
#include <rtems/system.h> #include <rtems/system.h>
#include <rtems/score/isr.h> #include <rtems/fatal.h>
#include <rtems/score/wkspace.h> #include <rtems/core/isr.h>
#include <rtems/core/wkspace.h>
void hppa_external_interrupt_initialize(void); void hppa_external_interrupt_initialize(void);
void hppa_external_interrupt_enable(unsigned32); void hppa_external_interrupt_enable(unsigned32);
@@ -103,6 +104,20 @@ void _CPU_Initialize(
_CPU_Table = *cpu_table; _CPU_Table = *cpu_table;
} }
/*PAGE
*
* _CPU_ISR_Get_level
*/
unsigned32 _CPU_ISR_Get_level(void)
{
int level;
HPPA_ASM_SSM(0, level); /* change no bits; just get copy */
if (level & HPPA_PSW_I)
return 1;
return 0;
}
/*PAGE /*PAGE
* *
* _CPU_ISR_install_raw_handler * _CPU_ISR_install_raw_handler

View File

@@ -20,7 +20,7 @@
* Note: * Note:
* This file is included by both C and assembler code ( -DASM ) * This file is included by both C and assembler code ( -DASM )
* *
* $Id$ * cpu.h,v 1.5 1995/09/11 19:24:10 joel Exp
*/ */
#ifndef __CPU_h #ifndef __CPU_h
@@ -30,9 +30,9 @@
extern "C" { extern "C" {
#endif #endif
#include <rtems/score/hppa.h> /* pick up machine definitions */ #include <rtems/core/hppa.h> /* pick up machine definitions */
#ifndef ASM #ifndef ASM
#include <rtems/score/hppatypes.h> #include <rtems/core/hppatypes.h>
#endif #endif
/* conditional compilation parameters */ /* conditional compilation parameters */
@@ -368,6 +368,9 @@ EXTERN void *_CPU_Interrupt_stack_high;
else HPPA_ASM_SSM(HPPA_PSW_I, ignore); \ else HPPA_ASM_SSM(HPPA_PSW_I, ignore); \
} }
/* return current level */
unsigned32 _CPU_ISR_Get_level( void );
/* end of ISR handler macros */ /* end of ISR handler macros */
/* /*

View File

@@ -1,4 +1,4 @@
# @(#)cpu_asm.S 1.6 - 95/05/16 # @(#)cpu_asm.S 1.7 - 95/09/21
# #
# #
# TODO: # TODO:
@@ -24,14 +24,14 @@
# Division Incorporated makes no representations about the # Division Incorporated makes no representations about the
# suitability of this software for any purpose. # suitability of this software for any purpose.
# #
# $Id$ # cpu_asm.S,v 1.5 1995/09/19 14:49:36 joel Exp
# #
#include <rtems/score/hppa.h> #include <rtems/core/hppa.h>
#include <rtems/score/cpu_asm.h> #include <rtems/core/cpu_asm.h>
#include <rtems/score/cpu.h> #include <rtems/core/cpu.h>
#include <rtems/score/offsets.h> #include <rtems/core/offsets.h>
.SPACE $PRIVATE$ .SPACE $PRIVATE$
.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31 .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31

View File

@@ -1,5 +1,5 @@
/* /*
* @(#)hppa.h 1.9 - 95/06/28 * @(#)hppa.h 1.13 - 95/09/21
* *
* *
* Description: * Description:
@@ -24,7 +24,7 @@
* Note: * Note:
* This file is included by both C and assembler code ( -DASM ) * This file is included by both C and assembler code ( -DASM )
* *
* $Id$ * hppa.h,v 1.4 1995/09/19 14:49:37 joel Exp
*/ */
#ifndef _INCLUDE_HPPA_H #ifndef _INCLUDE_HPPA_H
@@ -64,23 +64,23 @@ extern "C" {
* present in a particular member of the family. * present in a particular member of the family.
*/ */
#if !defined(CPU_MODEL_NAME) #if !defined(RTEMS_MODEL_NAME)
#if defined(hppa7100) #if defined(hppa7100)
#define CPU_MODEL_NAME "hppa 7100" #define RTEMS_MODEL_NAME "hppa 7100"
#elif defined(hppa7200) #elif defined(hppa7200)
#define CPU_MODEL_NAME "hppa 7200" #define RTEMS_MODEL_NAME "hppa 7200"
#else #else
#error "Unsupported CPU Model" #define RTEMS_MODEL_NAME Unsupported CPU Model /* cause an error on usage */
#endif #endif
#endif /* !defined(CPU_MODEL_NAME) */ #endif /* !defined(RTEMS_MODEL_NAME) */
/* /*
* Define the name of the CPU family. * Define the name of the CPU family.
@@ -222,6 +222,32 @@ extern "C" {
#define HPPA_CACHELINE_MASK (HPPA_CACHELINE_SIZE - 1) #define HPPA_CACHELINE_MASK (HPPA_CACHELINE_SIZE - 1)
/*
* TLB characteristics
*
* Flags and Access Control layout for using TLB protection insertion
*
* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |?|?|T|D|B|type |PL1|Pl2|U| access id |?|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
/*
* Access rights (type + PL1 + PL2)
*/
#define HPPA_PROT_R 0x00c00000 /* Read Only, no Write, no Execute */
#define HPPA_PROT_RW 0x01c00000 /* Read & Write Only, no Execute */
#define HPPA_PROT_RX 0x02c00000 /* Read & Execute Only, no Write */
#define HPPA_PROT_RWX 0x03c00000 /* Read, Write, Execute */
#define HPPA_PROT_X0 0x04c00000 /* Execute Only, Promote to Level 0 */
#define HPPA_PROT_X1 0x05c00000 /* Execute Only, Promote to Level 1 */
#define HPPA_PROT_X2 0x06c00000 /* Execute Only, Promote to Level 2 */
#define HPPA_PROT_X3 0x07c00000 /* Execute Only, Promote to Level 3 */
/* /*
* Inline macros for misc. interesting opcodes * Inline macros for misc. interesting opcodes
*/ */

View File

@@ -112,6 +112,9 @@ norst: frestore a0@+ | restore the fp state frame
* higher priority interrupt in the new context if * higher priority interrupt in the new context if
* permitted by the new interrupt level mask, and (2) when * permitted by the new interrupt level mask, and (2) when
* the original context regains the cpu. * the original context regains the cpu.
*
* XXX: Code for switching to a software maintained interrupt stack is
* not in place.
*/ */
#if ( M68K_HAS_VBR == 1) #if ( M68K_HAS_VBR == 1)
@@ -134,6 +137,13 @@ SYM (_ISR_Handler):
addql #1,SYM (_Thread_Dispatch_disable_level) | disable multitasking addql #1,SYM (_Thread_Dispatch_disable_level) | disable multitasking
moveml d0-d1/a0-a1,a7@- | save d0-d1,a0-a1 moveml d0-d1/a0-a1,a7@- | save d0-d1,a0-a1
/*
* NOTE FOR CPUs WITHOUT HARDWARE INTERRUPT STACK:
*
* After the interrupted codes registers have been saved, it is save
* to switch to the software maintained interrupt stack.
*/
#if ( M68K_HAS_VBR == 0) #if ( M68K_HAS_VBR == 0)
movel a7@(SAVED+JSR_OFFSET),d0 | assume the exception table at 0x0000 movel a7@(SAVED+JSR_OFFSET),d0 | assume the exception table at 0x0000
addql #6,d0 | points to a jump table (jsr) in RAM addql #6,d0 | points to a jump table (jsr) in RAM

View File

@@ -173,7 +173,7 @@ void _CPU_Signal_initialize( void )
void _CPU_Context_From_CPU_Init() void _CPU_Context_From_CPU_Init()
{ {
#if defined(hppa1_1) && defined(RTEMS_UNIXLIB) #if defined(hppa1_1) && defined(RTEMS_UNIXLIB_SETJMP)
/* /*
* 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.

View File

@@ -280,11 +280,11 @@ STATIC INLINE Heap_Block *_Heap_Block_at(
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
STATIC INLINE Heap_Block *_Heap_User_Block_at( STATIC INLINE Heap_Block *_Heap_User_block_at(
void *base void *base
); );

View File

@@ -280,11 +280,11 @@ STATIC INLINE Heap_Block *_Heap_Block_at(
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
STATIC INLINE Heap_Block *_Heap_User_Block_at( STATIC INLINE Heap_Block *_Heap_User_block_at(
void *base void *base
); );

View File

@@ -94,11 +94,11 @@ STATIC INLINE Heap_Block *_Heap_Block_at(
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
STATIC INLINE Heap_Block *_Heap_User_Block_at( STATIC INLINE Heap_Block *_Heap_User_block_at(
void *base void *base
) )
{ {

View File

@@ -94,11 +94,11 @@ STATIC INLINE Heap_Block *_Heap_Block_at(
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
STATIC INLINE Heap_Block *_Heap_User_Block_at( STATIC INLINE Heap_Block *_Heap_User_block_at(
void *base void *base
) )
{ {

View File

@@ -70,11 +70,11 @@
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
#define _Heap_User_Block_at( _base ) \ #define _Heap_User_block_at( _base ) \
_Heap_Block_at( \ _Heap_Block_at( \
(_base), \ (_base), \
-*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \ -*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \

View File

@@ -70,11 +70,11 @@
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
#define _Heap_User_Block_at( _base ) \ #define _Heap_User_block_at( _base ) \
_Heap_Block_at( \ _Heap_Block_at( \
(_base), \ (_base), \
-*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \ -*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \

View File

@@ -301,7 +301,7 @@ boolean _Heap_Size_of_user_area(
Heap_Block *next_block; Heap_Block *next_block;
unsigned32 the_size; unsigned32 the_size;
the_block = _Heap_User_Block_at( starting_address ); the_block = _Heap_User_block_at( starting_address );
if ( !_Heap_Is_block_in( the_heap, the_block ) || if ( !_Heap_Is_block_in( the_heap, the_block ) ||
_Heap_Is_block_free( the_block ) ) _Heap_Is_block_free( the_block ) )
@@ -346,7 +346,7 @@ boolean _Heap_Free(
Heap_Block *temporary_block; Heap_Block *temporary_block;
unsigned32 the_size; unsigned32 the_size;
the_block = _Heap_User_Block_at( starting_address ); the_block = _Heap_User_block_at( starting_address );
if ( !_Heap_Is_block_in( the_heap, the_block ) || if ( !_Heap_Is_block_in( the_heap, the_block ) ||
_Heap_Is_block_free( the_block ) ) { _Heap_Is_block_free( the_block ) ) {
@@ -430,6 +430,8 @@ void _Heap_Walk(
Heap_Block *the_block = 0; /* avoid warnings */ Heap_Block *the_block = 0; /* avoid warnings */
Heap_Block *next_block = 0; /* avoid warnings */ Heap_Block *next_block = 0; /* avoid warnings */
int notdone = 1; int notdone = 1;
int error = 0;
int passes = 0;
/* /*
* We don't want to allow walking the heap until we have * We don't want to allow walking the heap until we have
@@ -455,9 +457,14 @@ void _Heap_Walk(
if (the_block->back_flag != HEAP_DUMMY_FLAG) { if (the_block->back_flag != HEAP_DUMMY_FLAG) {
printf("PASS: %d Back flag of 1st block isn't HEAP_DUMMY_FLAG\n", source); printf("PASS: %d Back flag of 1st block isn't HEAP_DUMMY_FLAG\n", source);
error = 1;
} }
while (notdone) { while (notdone) {
passes++;
if (error && (passes > 10))
abort();
if (do_dump == TRUE) { if (do_dump == TRUE) {
printf("PASS: %d Block @ 0x%p Back %d, Front %d", printf("PASS: %d Block @ 0x%p Back %d, Front %d",
source, the_block, source, the_block,
@@ -477,6 +484,7 @@ void _Heap_Walk(
if ( the_block->front_flag != HEAP_DUMMY_FLAG ) { if ( the_block->front_flag != HEAP_DUMMY_FLAG ) {
next_block = _Heap_Next_block(the_block); next_block = _Heap_Next_block(the_block);
if ( the_block->front_flag != next_block->back_flag ) { if ( the_block->front_flag != next_block->back_flag ) {
error = 1;
printf("PASS: %d Front and back flags don't match\n", source); printf("PASS: %d Front and back flags don't match\n", source);
printf(" Current Block: Back - %d, Front - %d", printf(" Current Block: Back - %d, Front - %d",
the_block->back_flag, the_block->front_flag); the_block->back_flag, the_block->front_flag);
@@ -510,4 +518,7 @@ void _Heap_Walk(
else else
the_block = next_block; the_block = next_block;
} }
if (error)
abort();
} }

View File

@@ -1,5 +1,5 @@
/* /*
* @(#)genoffsets.c 1.5 - 95/05/16 * @(#)genoffsets.c 1.7 - 95/09/25
* *
* *
* genoffsets.c * genoffsets.c
@@ -82,7 +82,7 @@ printf(
"\n" \ "\n" \
); );
#if defined(hpux) && defined(__hppa__) #if defined(__hpux__) && defined(__hppa__)
/* /*
* Offsets of elements in the Context_control structure. * Offsets of elements in the Context_control structure.

View File

@@ -13,8 +13,8 @@
* $Id$ * $Id$
*/ */
#ifndef __SIMHPPA_h #ifndef __PXFL_BSP_h
#define __SIMHPPA_h #define __PXFL_BSP_h
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -23,7 +23,6 @@ extern "C" {
#include <rtems.h> #include <rtems.h>
#include <clockdrv.h> #include <clockdrv.h>
#include <rtems/ttydrv.h> #include <rtems/ttydrv.h>
#include <libcsupport.h>
/* /*
* Define the time limits for RTEMS Test Suite test durations. * Define the time limits for RTEMS Test Suite test durations.

View File

@@ -52,9 +52,7 @@
shm_config_table BSP_shm_cfgtbl; shm_config_table BSP_shm_cfgtbl;
void Shm_Cause_interrupt_simhppa( void Shm_Cause_interrupt_pxfl( rtems_unsigned32 node );
rtems_unsigned32 node
);
void Shm_Get_configuration( void Shm_Get_configuration(
rtems_unsigned32 localnode, rtems_unsigned32 localnode,
@@ -65,7 +63,7 @@ void Shm_Get_configuration(
BSP_shm_cfgtbl.length = 16 * KILOBYTE; BSP_shm_cfgtbl.length = 16 * KILOBYTE;
BSP_shm_cfgtbl.format = SHM_BIG; BSP_shm_cfgtbl.format = SHM_BIG;
BSP_shm_cfgtbl.cause_intr = Shm_Cause_interrupt_simhppa; BSP_shm_cfgtbl.cause_intr = Shm_Cause_interrupt_pxfl;
#ifdef NEUTRAL_BIG #ifdef NEUTRAL_BIG
BSP_shm_cfgtbl.convert = NULL_CONVERT; BSP_shm_cfgtbl.convert = NULL_CONVERT;

View File

@@ -1,4 +1,4 @@
/* void Shm_Cause_interrupt_simhppa( node ) /* void Shm_Cause_interrupt_pxfl( node )
* *
* This routine is the shared memory driver routine which * This routine is the shared memory driver routine which
* generates interrupts to other CPUs. * generates interrupts to other CPUs.
@@ -24,13 +24,11 @@
#include <rtems.h> #include <rtems.h>
#include <shm.h> #include <shm.h>
void Shm_Cause_interrupt_simhppa( void Shm_Cause_interrupt_pxfl(
rtems_unsigned32 node rtems_unsigned32 node
) )
{ {
Shm_Interrupt_information *intr; Shm_Interrupt_information *intr;
rtems_unsigned8 *u8;
rtems_unsigned16 *u16;
rtems_unsigned32 *u32; rtems_unsigned32 *u32;
rtems_unsigned32 value; rtems_unsigned32 value;
@@ -40,25 +38,13 @@ void Shm_Cause_interrupt_simhppa(
switch ( intr->length ) { switch ( intr->length ) {
case NO_INTERRUPT: case NO_INTERRUPT:
break; break;
case BYTE:
u8 = (rtems_unsigned8 *)intr->address;
fprintf(
stderr,
"Shm_Cause_interrupt_simhppa: Writes of unsigned8 not supported!!!\n"
);
rtems_shutdown_executive( 0 );
break;
case WORD:
u16 = (rtems_unsigned16 *)intr->address;
fprintf(
stderr,
"Shm_Cause_interrupt_simhppa: Writes of unsigned8 not supported!!!\n"
);
rtems_shutdown_executive( 0 );
break;
case LONG: case LONG:
u32 = (rtems_unsigned32 *)intr->address; u32 = (rtems_unsigned32 *)intr->address;
HPPA_ASM_STWAS( value, 0, u32 ); HPPA_ASM_STWAS( value, 0, u32 );
break; break;
default:
fprintf( stderr, "Shm_Cause_interrupt_pxfl: Unsupported length!!!\n" );
rtems_shutdown_executive( 0 );
break;
} }
} }

View File

@@ -55,7 +55,7 @@ set_vector( /* returns old vector */
else if ((vector >= HPPA_INTERRUPT_BSP_BASE) && else if ((vector >= HPPA_INTERRUPT_BSP_BASE) &&
(vector < (HPPA_INTERRUPT_BSP_BASE + HPPA_BSP_INTERRUPTS))) (vector < (HPPA_INTERRUPT_BSP_BASE + HPPA_BSP_INTERRUPTS)))
{ {
simhppa_interrupt_install(handler, pxfl_interrupt_install(handler,
vector - HPPA_INTERRUPT_BSP_BASE, vector - HPPA_INTERRUPT_BSP_BASE,
(rtems_isr_entry *) &previous_isr); (rtems_isr_entry *) &previous_isr);
} }

View File

@@ -19,6 +19,7 @@ MEMORY
} }
m302 = 0xf7f000; m302 = 0xf7f000;
_VBR = 0x000000; /* location of the VBR table (in RAM) */
SECTIONS SECTIONS
{ {

View File

@@ -19,7 +19,6 @@
#include <rtems.h> #include <rtems.h>
#include <stdio.h> #include <stdio.h>
#include <libcsupport.h>
#include "shm.h" #include "shm.h"

View File

@@ -22,6 +22,8 @@
#include "shm.h" #include "shm.h"
void MPCI_Fatal( void MPCI_Fatal(
Internal_errors_Source source,
boolean is_internal,
rtems_unsigned32 error rtems_unsigned32 error
) )
{ {

View File

@@ -33,6 +33,7 @@ Shm_Envelope_control *Shm_Locked_queue_Get(
tmp_ecb = NULL; tmp_ecb = NULL;
Shm_Lock( lq_cb ); Shm_Lock( lq_cb );
tmpfront = Shm_Convert(lq_cb->front); tmpfront = Shm_Convert(lq_cb->front);
if ( tmpfront != Shm_Locked_queue_End_of_list ) { if ( tmpfront != Shm_Locked_queue_End_of_list ) {
tmp_ecb = &Shm_Envelopes[ tmpfront ]; tmp_ecb = &Shm_Envelopes[ tmpfront ];
@@ -41,6 +42,7 @@ Shm_Envelope_control *Shm_Locked_queue_Get(
lq_cb->rear = Shm_Locked_queue_End_of_list; lq_cb->rear = Shm_Locked_queue_End_of_list;
tmp_ecb->next = Shm_Locked_queue_Not_on_list; tmp_ecb->next = Shm_Locked_queue_Not_on_list;
} }
Shm_Unlock( lq_cb ); Shm_Unlock( lq_cb );
return( tmp_ecb ); return( tmp_ecb );
} }

View File

@@ -470,7 +470,11 @@ void Shm_Locked_queue_Initialize(
/* portable routines */ /* portable routines */
void Init_env_pool(); void Init_env_pool();
void Shm_Print_statistics( void ); void Shm_Print_statistics( void );
void MPCI_Fatal( rtems_unsigned32 ); void MPCI_Fatal(
Internal_errors_Source source,
boolean is_internal,
rtems_unsigned32 error
);
rtems_task Shm_Cause_interrupt( rtems_unsigned32 ); rtems_task Shm_Cause_interrupt( rtems_unsigned32 );
void Shm_Poll(); void Shm_Poll();
void Shm_setclockvec(); void Shm_setclockvec();

View File

@@ -470,7 +470,11 @@ void Shm_Locked_queue_Initialize(
/* portable routines */ /* portable routines */
void Init_env_pool(); void Init_env_pool();
void Shm_Print_statistics( void ); void Shm_Print_statistics( void );
void MPCI_Fatal( rtems_unsigned32 ); void MPCI_Fatal(
Internal_errors_Source source,
boolean is_internal,
rtems_unsigned32 error
);
rtems_task Shm_Cause_interrupt( rtems_unsigned32 ); rtems_task Shm_Cause_interrupt( rtems_unsigned32 );
void Shm_Poll(); void Shm_Poll();
void Shm_setclockvec(); void Shm_setclockvec();

View File

@@ -24,7 +24,6 @@ extern "C" {
#include <clockdrv.h> #include <clockdrv.h>
#include <console.h> #include <console.h>
#include <iosupp.h> #include <iosupp.h>
#include <libcsupport.h>
/* /*
* Define the time limits for RTEMS Test Suite test durations. * Define the time limits for RTEMS Test Suite test durations.

View File

@@ -195,6 +195,11 @@ bsp_postdriver_hook(void)
if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2))
rtems_fatal_error_occurred('STIO'); rtems_fatal_error_occurred('STIO');
#endif #endif
#if defined(MALLOC_STATS)
atexit(malloc_dump);
#endif
} }
/* /*

View File

@@ -8,8 +8,6 @@
* type - 0 indicates raw hardware connect * type - 0 indicates raw hardware connect
* 1 indicates RTEMS interrupt connect * 1 indicates RTEMS interrupt connect
* *
* NOTE 'type' is ignored on hppa; all interrupts are owned by RTEMS
*
* RETURNS: * RETURNS:
* address of previous interrupt handler * address of previous interrupt handler
* *
@@ -26,16 +24,6 @@
#include <bsp.h> #include <bsp.h>
/*
* Install an interrupt handler in the right place
* given its vector number from cpu/hppa.h
* There are 2 places an interrupt can be installed
* _ISR_Vector_table
* bsp interrupt XXX: nyi
*
* We decide which based on the vector number
*/
rtems_isr_entry rtems_isr_entry
set_vector( /* returns old vector */ set_vector( /* returns old vector */
rtems_isr_entry handler, /* isr routine */ rtems_isr_entry handler, /* isr routine */

View File

@@ -39,7 +39,7 @@
* EXAMPLE * EXAMPLE
* if ((fd = open(pathname, O_RDNLY)) < 0) * if ((fd = open(pathname, O_RDNLY)) < 0)
* { * {
* rtems_error(FLOSS_ERROR_ERRNO, "open of '%s' failed", pathname); * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname);
* goto failed; * goto failed;
* } * }
*/ */

View File

@@ -14,9 +14,6 @@
*/ */
#include <rtems.h> #include <rtems.h>
#ifdef RTEMS_LIBC
#include <memory.h>
#endif
#include "libcsupport.h" #include "libcsupport.h"
#ifdef RTEMS_NEWLIB #ifdef RTEMS_NEWLIB
#include <sys/reent.h> #include <sys/reent.h>
@@ -29,22 +26,31 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
/*
* XXX: Do we really need to duplicate these? It appears that they
* only cause typing problems.
*/
#if 0
void *malloc(size_t);
void *calloc(size_t, size_t);
void *realloc(void *, size_t);
void free(void *);
void *sbrk(size_t);
#endif
rtems_id RTEMS_Malloc_Heap; rtems_id RTEMS_Malloc_Heap;
size_t RTEMS_Malloc_Sbrk_amount; size_t RTEMS_Malloc_Sbrk_amount;
#ifdef RTEMS_DEBUG
#define MALLOC_STATS
#endif
#ifdef MALLOC_STATS
#define MSBUMP(f,n) malloc_stats.f += (n)
struct {
unsigned32 space_available; /* current size of malloc area */
unsigned32 malloc_calls; /* # calls to malloc */
unsigned32 free_calls;
unsigned32 realloc_calls;
unsigned32 calloc_calls;
unsigned32 max_depth; /* most ever malloc'd at 1 time */
unsigned64 lifetime_allocated;
unsigned64 lifetime_freed;
} malloc_stats;
#else /* No malloc_stats */
#define MSBUMP(f,n)
#endif
void RTEMS_Malloc_Initialize( void RTEMS_Malloc_Initialize(
void *start, void *start,
size_t length, size_t length,
@@ -78,7 +84,7 @@ void RTEMS_Malloc_Initialize(
u32_address = (u32_address + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); u32_address = (u32_address + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
/* /*
* Adjust the length by whatever we aligned by * adjust the length by whatever we aligned by
*/ */
length -= u32_address - old_address; length -= u32_address - old_address;
@@ -97,12 +103,19 @@ void RTEMS_Malloc_Initialize(
rtems_build_name( 'H', 'E', 'A', 'P' ), rtems_build_name( 'H', 'E', 'A', 'P' ),
starting_address, starting_address,
length, length,
8, /* XXX : use CPU dependent RTEMS constant */ CPU_ALIGNMENT,
RTEMS_DEFAULT_ATTRIBUTES, RTEMS_DEFAULT_ATTRIBUTES,
&RTEMS_Malloc_Heap &RTEMS_Malloc_Heap
); );
if ( status != RTEMS_SUCCESSFUL ) if ( status != RTEMS_SUCCESSFUL )
rtems_fatal_error_occurred( status ); rtems_fatal_error_occurred( status );
#ifdef MALLOC_STATS
/* zero all the stats */
(void) memset(&malloc_stats, 0, sizeof(malloc_stats));
#endif
MSBUMP(space_available, length);
} }
void *malloc( void *malloc(
@@ -115,6 +128,8 @@ void *malloc(
rtems_unsigned32 sbrk_amount; rtems_unsigned32 sbrk_amount;
rtems_status_code status; rtems_status_code status;
MSBUMP(malloc_calls, 1);
if ( !size ) if ( !size )
return (void *) 0; return (void *) 0;
@@ -149,11 +164,6 @@ void *malloc(
if (((rtems_unsigned32)starting_address = sbrk(the_size)) == -1) if (((rtems_unsigned32)starting_address = sbrk(the_size)) == -1)
return (void *) 0; return (void *) 0;
/*
fprintf(stderr, "Extended the C heap starting at 0x%x for %d bytes\n",
(unsigned32)starting_address, the_size);
*/
status = rtems_region_extend( status = rtems_region_extend(
RTEMS_Malloc_Heap, RTEMS_Malloc_Heap,
starting_address, starting_address,
@@ -161,10 +171,12 @@ void *malloc(
); );
if ( status != RTEMS_SUCCESSFUL ) { if ( status != RTEMS_SUCCESSFUL ) {
sbrk(-the_size); sbrk(-the_size);
return(FALSE);
errno = ENOMEM; errno = ENOMEM;
return (void *) 0; return (void *) 0;
} }
MSBUMP(space_available, the_size);
status = rtems_region_get_segment( status = rtems_region_get_segment(
RTEMS_Malloc_Heap, RTEMS_Malloc_Heap,
size, size,
@@ -178,6 +190,17 @@ void *malloc(
} }
} }
#ifdef MALLOC_STATS
if (return_this)
{
unsigned32 current_depth;
MSBUMP(lifetime_allocated, size);
current_depth = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
if (current_depth > malloc_stats.max_depth)
malloc_stats.max_depth = current_depth;
}
#endif
return return_this; return return_this;
} }
@@ -189,6 +212,8 @@ void *calloc(
register char *cptr; register char *cptr;
int length; int length;
MSBUMP(calloc_calls, 1);
length = nelem * elsize; length = nelem * elsize;
cptr = malloc( length ); cptr = malloc( length );
if ( cptr ) if ( cptr )
@@ -206,6 +231,8 @@ void *realloc(
rtems_status_code status; rtems_status_code status;
char *new_area; char *new_area;
MSBUMP(realloc_calls, 1);
if ( !ptr ) if ( !ptr )
return malloc( size ); return malloc( size );
@@ -214,18 +241,18 @@ void *realloc(
return (void *) 0; return (void *) 0;
} }
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size );
if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL;
return (void *) 0;
}
new_area = malloc( size ); new_area = malloc( size );
if ( !new_area ) { if ( !new_area ) {
free( ptr ); free( ptr );
return (void *) 0; return (void *) 0;
} }
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size );
if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL;
return (void *) 0;
}
memcpy( new_area, ptr, (size < old_size) ? size : old_size ); memcpy( new_area, ptr, (size < old_size) ? size : old_size );
free( ptr ); free( ptr );
@@ -239,9 +266,21 @@ void free(
{ {
rtems_status_code status; rtems_status_code status;
MSBUMP(free_calls, 1);
if ( !ptr ) if ( !ptr )
return; return;
#ifdef MALLOC_STATS
{
unsigned32 size;
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &size );
if ( status == RTEMS_SUCCESSFUL ) {
MSBUMP(lifetime_freed, size);
}
}
#endif
status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr ); status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr );
if ( status != RTEMS_SUCCESSFUL ) { if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL; errno = EINVAL;
@@ -249,6 +288,35 @@ void free(
} }
} }
#ifdef MALLOC_STATS
/*
* Dump the malloc statistics
* May be called via atexit() (installable by our bsp) or
* at any time by user
*/
void malloc_dump(void)
{
unsigned32 allocated = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
printf("Malloc stats\n");
printf(" avail:%uk allocated:%uk (%d%%) max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
(unsigned int) malloc_stats.space_available / 1024,
(unsigned int) allocated / 1024,
/* avoid float! */
(allocated * 100) / malloc_stats.space_available,
(unsigned int) malloc_stats.max_depth / 1024,
(malloc_stats.max_depth * 100) / malloc_stats.space_available,
(unsigned long long) malloc_stats.lifetime_allocated / 1024,
(unsigned long long) malloc_stats.lifetime_freed / 1024);
printf(" Call counts: malloc:%d free:%d realloc:%d calloc:%d\n",
malloc_stats.malloc_calls,
malloc_stats.free_calls,
malloc_stats.realloc_calls,
malloc_stats.calloc_calls);
}
#endif
/* /*
* "Reentrant" versions of the above routines implemented above. * "Reentrant" versions of the above routines implemented above.
*/ */

View File

@@ -15,9 +15,12 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <bsp.h>
#include <rtems/libio.h> #include <rtems/libio.h>
/* should get this from bsp.h, but it is not installed yet */
rtems_isr_entry set_vector(rtems_isr_entry, rtems_vector_number, int);
extern rtems_configuration_table BSP_Configuration;
#include <stdlib.h> /* for atexit() */ #include <stdlib.h> /* for atexit() */
extern rtems_cpu_table Cpu_table; /* owned by BSP */ extern rtems_cpu_table Cpu_table; /* owned by BSP */

View File

@@ -39,7 +39,7 @@
* EXAMPLE * EXAMPLE
* if ((fd = open(pathname, O_RDNLY)) < 0) * if ((fd = open(pathname, O_RDNLY)) < 0)
* { * {
* rtems_error(FLOSS_ERROR_ERRNO, "open of '%s' failed", pathname); * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname);
* goto failed; * goto failed;
* } * }
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* @(#)extension.c 1.3 - 95/07/31 * @(#)extension.c 1.6 - 95/09/25
* *
* *
* RTEMS Monitor extension support * RTEMS Monitor extension support
@@ -21,22 +21,22 @@ rtems_monitor_extension_canonical(
Extension_Control *rtems_extension = (Extension_Control *) extension_void; Extension_Control *rtems_extension = (Extension_Control *) extension_void;
rtems_extensions_table *e = &rtems_extension->Extension.Callouts; rtems_extensions_table *e = &rtems_extension->Extension.Callouts;
rtems_monitor_symbol_canonical_by_value(&canonical_extension->create, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_create,
e->thread_create); e->thread_create);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->start, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_start,
e->thread_start); e->thread_start);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->restart, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_restart,
e->thread_restart); e->thread_restart);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->delete, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_delete,
e->thread_delete); e->thread_delete);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->tswitch, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_tswitch,
e->thread_switch); e->thread_switch);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->begin, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_begin,
e->thread_begin); e->thread_begin);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->exitted, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_exitted,
e->thread_exitted); e->thread_exitted);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->fatal, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_fatal,
e->fatal); e->fatal);
} }
@@ -72,29 +72,29 @@ rtems_monitor_extension_dump(
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("create: "); length += printf("create: ");
length += rtems_monitor_symbol_dump(&monitor_extension->create, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_create, verbose);
length += printf("; start: "); length += printf("; start: ");
length += rtems_monitor_symbol_dump(&monitor_extension->start, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_start, verbose);
length += printf("; restart: "); length += printf("; restart: ");
length += rtems_monitor_symbol_dump(&monitor_extension->restart, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_restart, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("delete: "); length += printf("delete: ");
length += rtems_monitor_symbol_dump(&monitor_extension->delete, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_delete, verbose);
length += printf("; switch: "); length += printf("; switch: ");
length += rtems_monitor_symbol_dump(&monitor_extension->tswitch, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_tswitch, verbose);
length += printf("; begin: "); length += printf("; begin: ");
length += rtems_monitor_symbol_dump(&monitor_extension->begin, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_begin, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("exitted: "); length += printf("exitted: ");
length += rtems_monitor_symbol_dump(&monitor_extension->exitted, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_exitted, verbose);
length += printf("; fatal: "); length += printf("; fatal: ");
length += rtems_monitor_symbol_dump(&monitor_extension->fatal, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_fatal, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
printf("\n"); printf("\n");

View File

@@ -184,7 +184,7 @@ rtems_symbol_string_compare(const void *e1,
void void
rtems_symbol_sort(rtems_symbol_table_t *table) rtems_symbol_sort(rtems_symbol_table_t *table)
{ {
#ifdef simhppa #ifdef RTEMS_ON_SIMULATOR
printf("Sorting symbols ... "); /* so slow we need a msg */ printf("Sorting symbols ... "); /* so slow we need a msg */
fflush(stdout); fflush(stdout);
#endif #endif
@@ -195,7 +195,7 @@ rtems_symbol_sort(rtems_symbol_table_t *table)
qsort((void *) table->symbols, (size_t) table->next, qsort((void *) table->symbols, (size_t) table->next,
sizeof(rtems_symbol_t), rtems_symbol_string_compare); sizeof(rtems_symbol_t), rtems_symbol_string_compare);
#ifdef simhppa #ifdef RTEMS_ON_SIMULATOR
/* so slow we need a msg */ /* so slow we need a msg */
printf("done\n"); printf("done\n");
#endif #endif
@@ -401,11 +401,11 @@ rtems_monitor_symbol_dump(
{ {
if (canonical_symbol->offset == 0) if (canonical_symbol->offset == 0)
length += printf("%.*s", length += printf("%.*s",
sizeof(canonical_symbol->name), (int) sizeof(canonical_symbol->name),
canonical_symbol->name); canonical_symbol->name);
else else
length += printf("<%.*s+0x%x>", length += printf("<%.*s+0x%x>",
sizeof(canonical_symbol->name), (int) sizeof(canonical_symbol->name),
canonical_symbol->name, canonical_symbol->name,
canonical_symbol->offset); canonical_symbol->offset);
if (verbose) if (verbose)

View File

@@ -140,14 +140,14 @@ typedef struct {
rtems_id id; rtems_id id;
rtems_name name; rtems_name name;
/* end of common portion */ /* end of common portion */
rtems_monitor_symbol_t create; rtems_monitor_symbol_t e_create;
rtems_monitor_symbol_t start; rtems_monitor_symbol_t e_start;
rtems_monitor_symbol_t restart; rtems_monitor_symbol_t e_restart;
rtems_monitor_symbol_t delete; rtems_monitor_symbol_t e_delete;
rtems_monitor_symbol_t tswitch; rtems_monitor_symbol_t e_tswitch;
rtems_monitor_symbol_t begin; rtems_monitor_symbol_t e_begin;
rtems_monitor_symbol_t exitted; rtems_monitor_symbol_t e_exitted;
rtems_monitor_symbol_t fatal; rtems_monitor_symbol_t e_fatal;
} rtems_monitor_extension_t; } rtems_monitor_extension_t;
/* /*

View File

@@ -128,10 +128,12 @@ void Stack_check_Initialize( void )
rtems_status_code status; rtems_status_code status;
Objects_Id id_ignored; Objects_Id id_ignored;
unsigned32 *p; unsigned32 *p;
#if 0
unsigned32 i; unsigned32 i;
unsigned32 class_index; unsigned32 class_index;
Thread_Control *the_thread; Thread_Control *the_thread;
Objects_Information *information; Objects_Information *information;
#endif
if (stack_check_initialized) if (stack_check_initialized)
return; return;
@@ -420,7 +422,11 @@ void Stack_check_Dump_threads_usage(
* Stack_check_Fatal_extension * Stack_check_Fatal_extension
*/ */
void Stack_check_Fatal_extension( unsigned32 status ) void Stack_check_Fatal_extension(
Internal_errors_Source source,
boolean is_internal,
unsigned32 status
)
{ {
if (status == 0) if (status == 0)
Stack_check_Dump_usage(); Stack_check_Dump_usage();
@@ -443,6 +449,7 @@ void Stack_check_Dump_usage( void )
if (stack_check_initialized == 0) if (stack_check_initialized == 0)
return; return;
printf("Stack usage by thread\n");
printf( printf(
" ID NAME LOW HIGH AVAILABLE USED\n" " ID NAME LOW HIGH AVAILABLE USED\n"
); );

View File

@@ -77,7 +77,9 @@ void Stack_check_Switch_extension(
*/ */
void Stack_check_Fatal_extension( void Stack_check_Fatal_extension(
unsigned32 Internal_errors_Source source,
boolean is_internal,
unsigned32 status
); );
/* /*

View File

@@ -19,7 +19,6 @@
#include <rtems.h> #include <rtems.h>
#include <stdio.h> #include <stdio.h>
#include <libcsupport.h>
#include "shm.h" #include "shm.h"

View File

@@ -22,6 +22,8 @@
#include "shm.h" #include "shm.h"
void MPCI_Fatal( void MPCI_Fatal(
Internal_errors_Source source,
boolean is_internal,
rtems_unsigned32 error rtems_unsigned32 error
) )
{ {

View File

@@ -33,6 +33,7 @@ Shm_Envelope_control *Shm_Locked_queue_Get(
tmp_ecb = NULL; tmp_ecb = NULL;
Shm_Lock( lq_cb ); Shm_Lock( lq_cb );
tmpfront = Shm_Convert(lq_cb->front); tmpfront = Shm_Convert(lq_cb->front);
if ( tmpfront != Shm_Locked_queue_End_of_list ) { if ( tmpfront != Shm_Locked_queue_End_of_list ) {
tmp_ecb = &Shm_Envelopes[ tmpfront ]; tmp_ecb = &Shm_Envelopes[ tmpfront ];
@@ -41,6 +42,7 @@ Shm_Envelope_control *Shm_Locked_queue_Get(
lq_cb->rear = Shm_Locked_queue_End_of_list; lq_cb->rear = Shm_Locked_queue_End_of_list;
tmp_ecb->next = Shm_Locked_queue_Not_on_list; tmp_ecb->next = Shm_Locked_queue_Not_on_list;
} }
Shm_Unlock( lq_cb ); Shm_Unlock( lq_cb );
return( tmp_ecb ); return( tmp_ecb );
} }

View File

@@ -470,7 +470,11 @@ void Shm_Locked_queue_Initialize(
/* portable routines */ /* portable routines */
void Init_env_pool(); void Init_env_pool();
void Shm_Print_statistics( void ); void Shm_Print_statistics( void );
void MPCI_Fatal( rtems_unsigned32 ); void MPCI_Fatal(
Internal_errors_Source source,
boolean is_internal,
rtems_unsigned32 error
);
rtems_task Shm_Cause_interrupt( rtems_unsigned32 ); rtems_task Shm_Cause_interrupt( rtems_unsigned32 );
void Shm_Poll(); void Shm_Poll();
void Shm_setclockvec(); void Shm_setclockvec();

View File

@@ -39,7 +39,7 @@
* EXAMPLE * EXAMPLE
* if ((fd = open(pathname, O_RDNLY)) < 0) * if ((fd = open(pathname, O_RDNLY)) < 0)
* { * {
* rtems_error(FLOSS_ERROR_ERRNO, "open of '%s' failed", pathname); * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname);
* goto failed; * goto failed;
* } * }
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* @(#)extension.c 1.3 - 95/07/31 * @(#)extension.c 1.6 - 95/09/25
* *
* *
* RTEMS Monitor extension support * RTEMS Monitor extension support
@@ -21,22 +21,22 @@ rtems_monitor_extension_canonical(
Extension_Control *rtems_extension = (Extension_Control *) extension_void; Extension_Control *rtems_extension = (Extension_Control *) extension_void;
rtems_extensions_table *e = &rtems_extension->Extension.Callouts; rtems_extensions_table *e = &rtems_extension->Extension.Callouts;
rtems_monitor_symbol_canonical_by_value(&canonical_extension->create, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_create,
e->thread_create); e->thread_create);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->start, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_start,
e->thread_start); e->thread_start);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->restart, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_restart,
e->thread_restart); e->thread_restart);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->delete, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_delete,
e->thread_delete); e->thread_delete);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->tswitch, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_tswitch,
e->thread_switch); e->thread_switch);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->begin, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_begin,
e->thread_begin); e->thread_begin);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->exitted, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_exitted,
e->thread_exitted); e->thread_exitted);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->fatal, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_fatal,
e->fatal); e->fatal);
} }
@@ -72,29 +72,29 @@ rtems_monitor_extension_dump(
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("create: "); length += printf("create: ");
length += rtems_monitor_symbol_dump(&monitor_extension->create, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_create, verbose);
length += printf("; start: "); length += printf("; start: ");
length += rtems_monitor_symbol_dump(&monitor_extension->start, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_start, verbose);
length += printf("; restart: "); length += printf("; restart: ");
length += rtems_monitor_symbol_dump(&monitor_extension->restart, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_restart, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("delete: "); length += printf("delete: ");
length += rtems_monitor_symbol_dump(&monitor_extension->delete, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_delete, verbose);
length += printf("; switch: "); length += printf("; switch: ");
length += rtems_monitor_symbol_dump(&monitor_extension->tswitch, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_tswitch, verbose);
length += printf("; begin: "); length += printf("; begin: ");
length += rtems_monitor_symbol_dump(&monitor_extension->begin, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_begin, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("exitted: "); length += printf("exitted: ");
length += rtems_monitor_symbol_dump(&monitor_extension->exitted, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_exitted, verbose);
length += printf("; fatal: "); length += printf("; fatal: ");
length += rtems_monitor_symbol_dump(&monitor_extension->fatal, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_fatal, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
printf("\n"); printf("\n");

View File

@@ -184,7 +184,7 @@ rtems_symbol_string_compare(const void *e1,
void void
rtems_symbol_sort(rtems_symbol_table_t *table) rtems_symbol_sort(rtems_symbol_table_t *table)
{ {
#ifdef simhppa #ifdef RTEMS_ON_SIMULATOR
printf("Sorting symbols ... "); /* so slow we need a msg */ printf("Sorting symbols ... "); /* so slow we need a msg */
fflush(stdout); fflush(stdout);
#endif #endif
@@ -195,7 +195,7 @@ rtems_symbol_sort(rtems_symbol_table_t *table)
qsort((void *) table->symbols, (size_t) table->next, qsort((void *) table->symbols, (size_t) table->next,
sizeof(rtems_symbol_t), rtems_symbol_string_compare); sizeof(rtems_symbol_t), rtems_symbol_string_compare);
#ifdef simhppa #ifdef RTEMS_ON_SIMULATOR
/* so slow we need a msg */ /* so slow we need a msg */
printf("done\n"); printf("done\n");
#endif #endif
@@ -401,11 +401,11 @@ rtems_monitor_symbol_dump(
{ {
if (canonical_symbol->offset == 0) if (canonical_symbol->offset == 0)
length += printf("%.*s", length += printf("%.*s",
sizeof(canonical_symbol->name), (int) sizeof(canonical_symbol->name),
canonical_symbol->name); canonical_symbol->name);
else else
length += printf("<%.*s+0x%x>", length += printf("<%.*s+0x%x>",
sizeof(canonical_symbol->name), (int) sizeof(canonical_symbol->name),
canonical_symbol->name, canonical_symbol->name,
canonical_symbol->offset); canonical_symbol->offset);
if (verbose) if (verbose)

View File

@@ -140,14 +140,14 @@ typedef struct {
rtems_id id; rtems_id id;
rtems_name name; rtems_name name;
/* end of common portion */ /* end of common portion */
rtems_monitor_symbol_t create; rtems_monitor_symbol_t e_create;
rtems_monitor_symbol_t start; rtems_monitor_symbol_t e_start;
rtems_monitor_symbol_t restart; rtems_monitor_symbol_t e_restart;
rtems_monitor_symbol_t delete; rtems_monitor_symbol_t e_delete;
rtems_monitor_symbol_t tswitch; rtems_monitor_symbol_t e_tswitch;
rtems_monitor_symbol_t begin; rtems_monitor_symbol_t e_begin;
rtems_monitor_symbol_t exitted; rtems_monitor_symbol_t e_exitted;
rtems_monitor_symbol_t fatal; rtems_monitor_symbol_t e_fatal;
} rtems_monitor_extension_t; } rtems_monitor_extension_t;
/* /*

View File

@@ -128,10 +128,12 @@ void Stack_check_Initialize( void )
rtems_status_code status; rtems_status_code status;
Objects_Id id_ignored; Objects_Id id_ignored;
unsigned32 *p; unsigned32 *p;
#if 0
unsigned32 i; unsigned32 i;
unsigned32 class_index; unsigned32 class_index;
Thread_Control *the_thread; Thread_Control *the_thread;
Objects_Information *information; Objects_Information *information;
#endif
if (stack_check_initialized) if (stack_check_initialized)
return; return;
@@ -420,7 +422,11 @@ void Stack_check_Dump_threads_usage(
* Stack_check_Fatal_extension * Stack_check_Fatal_extension
*/ */
void Stack_check_Fatal_extension( unsigned32 status ) void Stack_check_Fatal_extension(
Internal_errors_Source source,
boolean is_internal,
unsigned32 status
)
{ {
if (status == 0) if (status == 0)
Stack_check_Dump_usage(); Stack_check_Dump_usage();
@@ -443,6 +449,7 @@ void Stack_check_Dump_usage( void )
if (stack_check_initialized == 0) if (stack_check_initialized == 0)
return; return;
printf("Stack usage by thread\n");
printf( printf(
" ID NAME LOW HIGH AVAILABLE USED\n" " ID NAME LOW HIGH AVAILABLE USED\n"
); );

View File

@@ -77,7 +77,9 @@ void Stack_check_Switch_extension(
*/ */
void Stack_check_Fatal_extension( void Stack_check_Fatal_extension(
unsigned32 Internal_errors_Source source,
boolean is_internal,
unsigned32 status
); );
/* /*

View File

@@ -29,7 +29,6 @@
#include <rtems.h> #include <rtems.h>
#include <stdio.h> #include <stdio.h>
#include <libcsupport.h>
#include <iostream.h> #include <iostream.h>
extern "C" { extern "C" {
@@ -128,7 +127,7 @@ cdtest(void)
// in many implementations in order to get global constructors // in many implementations in order to get global constructors
// run. // run.
// //
// Ref: c/src/lib/libbsp/hppa1_1/simhppa/startup/bspstart.c // Ref: c/src/lib/libbsp/hppa1_1/pxfl/startup/bspstart.c
// //

View File

@@ -26,7 +26,6 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <libcsupport.h>
#define FOREVER 1 /* infinite loop */ #define FOREVER 1 /* infinite loop */
@@ -95,8 +94,6 @@ extern "C" {
putchar( '\n' ); \ putchar( '\n' ); \
} }
#define put_buffer( _buffer ) XYZ( _buffer )
#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \ #define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
{ (TB)->year = YR; \ { (TB)->year = YR; \
(TB)->month = MON; \ (TB)->month = MON; \

View File

@@ -39,7 +39,7 @@
* EXAMPLE * EXAMPLE
* if ((fd = open(pathname, O_RDNLY)) < 0) * if ((fd = open(pathname, O_RDNLY)) < 0)
* { * {
* rtems_error(FLOSS_ERROR_ERRNO, "open of '%s' failed", pathname); * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname);
* goto failed; * goto failed;
* } * }
*/ */

View File

@@ -14,9 +14,6 @@
*/ */
#include <rtems.h> #include <rtems.h>
#ifdef RTEMS_LIBC
#include <memory.h>
#endif
#include "libcsupport.h" #include "libcsupport.h"
#ifdef RTEMS_NEWLIB #ifdef RTEMS_NEWLIB
#include <sys/reent.h> #include <sys/reent.h>
@@ -29,22 +26,31 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
/*
* XXX: Do we really need to duplicate these? It appears that they
* only cause typing problems.
*/
#if 0
void *malloc(size_t);
void *calloc(size_t, size_t);
void *realloc(void *, size_t);
void free(void *);
void *sbrk(size_t);
#endif
rtems_id RTEMS_Malloc_Heap; rtems_id RTEMS_Malloc_Heap;
size_t RTEMS_Malloc_Sbrk_amount; size_t RTEMS_Malloc_Sbrk_amount;
#ifdef RTEMS_DEBUG
#define MALLOC_STATS
#endif
#ifdef MALLOC_STATS
#define MSBUMP(f,n) malloc_stats.f += (n)
struct {
unsigned32 space_available; /* current size of malloc area */
unsigned32 malloc_calls; /* # calls to malloc */
unsigned32 free_calls;
unsigned32 realloc_calls;
unsigned32 calloc_calls;
unsigned32 max_depth; /* most ever malloc'd at 1 time */
unsigned64 lifetime_allocated;
unsigned64 lifetime_freed;
} malloc_stats;
#else /* No malloc_stats */
#define MSBUMP(f,n)
#endif
void RTEMS_Malloc_Initialize( void RTEMS_Malloc_Initialize(
void *start, void *start,
size_t length, size_t length,
@@ -78,7 +84,7 @@ void RTEMS_Malloc_Initialize(
u32_address = (u32_address + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); u32_address = (u32_address + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
/* /*
* Adjust the length by whatever we aligned by * adjust the length by whatever we aligned by
*/ */
length -= u32_address - old_address; length -= u32_address - old_address;
@@ -97,12 +103,19 @@ void RTEMS_Malloc_Initialize(
rtems_build_name( 'H', 'E', 'A', 'P' ), rtems_build_name( 'H', 'E', 'A', 'P' ),
starting_address, starting_address,
length, length,
8, /* XXX : use CPU dependent RTEMS constant */ CPU_ALIGNMENT,
RTEMS_DEFAULT_ATTRIBUTES, RTEMS_DEFAULT_ATTRIBUTES,
&RTEMS_Malloc_Heap &RTEMS_Malloc_Heap
); );
if ( status != RTEMS_SUCCESSFUL ) if ( status != RTEMS_SUCCESSFUL )
rtems_fatal_error_occurred( status ); rtems_fatal_error_occurred( status );
#ifdef MALLOC_STATS
/* zero all the stats */
(void) memset(&malloc_stats, 0, sizeof(malloc_stats));
#endif
MSBUMP(space_available, length);
} }
void *malloc( void *malloc(
@@ -115,6 +128,8 @@ void *malloc(
rtems_unsigned32 sbrk_amount; rtems_unsigned32 sbrk_amount;
rtems_status_code status; rtems_status_code status;
MSBUMP(malloc_calls, 1);
if ( !size ) if ( !size )
return (void *) 0; return (void *) 0;
@@ -149,11 +164,6 @@ void *malloc(
if (((rtems_unsigned32)starting_address = sbrk(the_size)) == -1) if (((rtems_unsigned32)starting_address = sbrk(the_size)) == -1)
return (void *) 0; return (void *) 0;
/*
fprintf(stderr, "Extended the C heap starting at 0x%x for %d bytes\n",
(unsigned32)starting_address, the_size);
*/
status = rtems_region_extend( status = rtems_region_extend(
RTEMS_Malloc_Heap, RTEMS_Malloc_Heap,
starting_address, starting_address,
@@ -161,10 +171,12 @@ void *malloc(
); );
if ( status != RTEMS_SUCCESSFUL ) { if ( status != RTEMS_SUCCESSFUL ) {
sbrk(-the_size); sbrk(-the_size);
return(FALSE);
errno = ENOMEM; errno = ENOMEM;
return (void *) 0; return (void *) 0;
} }
MSBUMP(space_available, the_size);
status = rtems_region_get_segment( status = rtems_region_get_segment(
RTEMS_Malloc_Heap, RTEMS_Malloc_Heap,
size, size,
@@ -178,6 +190,17 @@ void *malloc(
} }
} }
#ifdef MALLOC_STATS
if (return_this)
{
unsigned32 current_depth;
MSBUMP(lifetime_allocated, size);
current_depth = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
if (current_depth > malloc_stats.max_depth)
malloc_stats.max_depth = current_depth;
}
#endif
return return_this; return return_this;
} }
@@ -189,6 +212,8 @@ void *calloc(
register char *cptr; register char *cptr;
int length; int length;
MSBUMP(calloc_calls, 1);
length = nelem * elsize; length = nelem * elsize;
cptr = malloc( length ); cptr = malloc( length );
if ( cptr ) if ( cptr )
@@ -206,6 +231,8 @@ void *realloc(
rtems_status_code status; rtems_status_code status;
char *new_area; char *new_area;
MSBUMP(realloc_calls, 1);
if ( !ptr ) if ( !ptr )
return malloc( size ); return malloc( size );
@@ -214,18 +241,18 @@ void *realloc(
return (void *) 0; return (void *) 0;
} }
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size );
if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL;
return (void *) 0;
}
new_area = malloc( size ); new_area = malloc( size );
if ( !new_area ) { if ( !new_area ) {
free( ptr ); free( ptr );
return (void *) 0; return (void *) 0;
} }
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &old_size );
if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL;
return (void *) 0;
}
memcpy( new_area, ptr, (size < old_size) ? size : old_size ); memcpy( new_area, ptr, (size < old_size) ? size : old_size );
free( ptr ); free( ptr );
@@ -239,9 +266,21 @@ void free(
{ {
rtems_status_code status; rtems_status_code status;
MSBUMP(free_calls, 1);
if ( !ptr ) if ( !ptr )
return; return;
#ifdef MALLOC_STATS
{
unsigned32 size;
status = rtems_region_get_segment_size( RTEMS_Malloc_Heap, ptr, &size );
if ( status == RTEMS_SUCCESSFUL ) {
MSBUMP(lifetime_freed, size);
}
}
#endif
status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr ); status = rtems_region_return_segment( RTEMS_Malloc_Heap, ptr );
if ( status != RTEMS_SUCCESSFUL ) { if ( status != RTEMS_SUCCESSFUL ) {
errno = EINVAL; errno = EINVAL;
@@ -249,6 +288,35 @@ void free(
} }
} }
#ifdef MALLOC_STATS
/*
* Dump the malloc statistics
* May be called via atexit() (installable by our bsp) or
* at any time by user
*/
void malloc_dump(void)
{
unsigned32 allocated = malloc_stats.lifetime_allocated - malloc_stats.lifetime_freed;
printf("Malloc stats\n");
printf(" avail:%uk allocated:%uk (%d%%) max:%uk (%d%%) lifetime:%Luk freed:%Luk\n",
(unsigned int) malloc_stats.space_available / 1024,
(unsigned int) allocated / 1024,
/* avoid float! */
(allocated * 100) / malloc_stats.space_available,
(unsigned int) malloc_stats.max_depth / 1024,
(malloc_stats.max_depth * 100) / malloc_stats.space_available,
(unsigned long long) malloc_stats.lifetime_allocated / 1024,
(unsigned long long) malloc_stats.lifetime_freed / 1024);
printf(" Call counts: malloc:%d free:%d realloc:%d calloc:%d\n",
malloc_stats.malloc_calls,
malloc_stats.free_calls,
malloc_stats.realloc_calls,
malloc_stats.calloc_calls);
}
#endif
/* /*
* "Reentrant" versions of the above routines implemented above. * "Reentrant" versions of the above routines implemented above.
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* @(#)extension.c 1.3 - 95/07/31 * @(#)extension.c 1.6 - 95/09/25
* *
* *
* RTEMS Monitor extension support * RTEMS Monitor extension support
@@ -21,22 +21,22 @@ rtems_monitor_extension_canonical(
Extension_Control *rtems_extension = (Extension_Control *) extension_void; Extension_Control *rtems_extension = (Extension_Control *) extension_void;
rtems_extensions_table *e = &rtems_extension->Extension.Callouts; rtems_extensions_table *e = &rtems_extension->Extension.Callouts;
rtems_monitor_symbol_canonical_by_value(&canonical_extension->create, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_create,
e->thread_create); e->thread_create);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->start, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_start,
e->thread_start); e->thread_start);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->restart, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_restart,
e->thread_restart); e->thread_restart);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->delete, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_delete,
e->thread_delete); e->thread_delete);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->tswitch, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_tswitch,
e->thread_switch); e->thread_switch);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->begin, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_begin,
e->thread_begin); e->thread_begin);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->exitted, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_exitted,
e->thread_exitted); e->thread_exitted);
rtems_monitor_symbol_canonical_by_value(&canonical_extension->fatal, rtems_monitor_symbol_canonical_by_value(&canonical_extension->e_fatal,
e->fatal); e->fatal);
} }
@@ -72,29 +72,29 @@ rtems_monitor_extension_dump(
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("create: "); length += printf("create: ");
length += rtems_monitor_symbol_dump(&monitor_extension->create, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_create, verbose);
length += printf("; start: "); length += printf("; start: ");
length += rtems_monitor_symbol_dump(&monitor_extension->start, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_start, verbose);
length += printf("; restart: "); length += printf("; restart: ");
length += rtems_monitor_symbol_dump(&monitor_extension->restart, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_restart, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("delete: "); length += printf("delete: ");
length += rtems_monitor_symbol_dump(&monitor_extension->delete, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_delete, verbose);
length += printf("; switch: "); length += printf("; switch: ");
length += rtems_monitor_symbol_dump(&monitor_extension->tswitch, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_tswitch, verbose);
length += printf("; begin: "); length += printf("; begin: ");
length += rtems_monitor_symbol_dump(&monitor_extension->begin, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_begin, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
length += rtems_monitor_pad(18, length); length += rtems_monitor_pad(18, length);
length += printf("exitted: "); length += printf("exitted: ");
length += rtems_monitor_symbol_dump(&monitor_extension->exitted, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_exitted, verbose);
length += printf("; fatal: "); length += printf("; fatal: ");
length += rtems_monitor_symbol_dump(&monitor_extension->fatal, verbose); length += rtems_monitor_symbol_dump(&monitor_extension->e_fatal, verbose);
length += printf("\n"); length += printf("\n");
length = 0; length = 0;
printf("\n"); printf("\n");

View File

@@ -184,7 +184,7 @@ rtems_symbol_string_compare(const void *e1,
void void
rtems_symbol_sort(rtems_symbol_table_t *table) rtems_symbol_sort(rtems_symbol_table_t *table)
{ {
#ifdef simhppa #ifdef RTEMS_ON_SIMULATOR
printf("Sorting symbols ... "); /* so slow we need a msg */ printf("Sorting symbols ... "); /* so slow we need a msg */
fflush(stdout); fflush(stdout);
#endif #endif
@@ -195,7 +195,7 @@ rtems_symbol_sort(rtems_symbol_table_t *table)
qsort((void *) table->symbols, (size_t) table->next, qsort((void *) table->symbols, (size_t) table->next,
sizeof(rtems_symbol_t), rtems_symbol_string_compare); sizeof(rtems_symbol_t), rtems_symbol_string_compare);
#ifdef simhppa #ifdef RTEMS_ON_SIMULATOR
/* so slow we need a msg */ /* so slow we need a msg */
printf("done\n"); printf("done\n");
#endif #endif
@@ -401,11 +401,11 @@ rtems_monitor_symbol_dump(
{ {
if (canonical_symbol->offset == 0) if (canonical_symbol->offset == 0)
length += printf("%.*s", length += printf("%.*s",
sizeof(canonical_symbol->name), (int) sizeof(canonical_symbol->name),
canonical_symbol->name); canonical_symbol->name);
else else
length += printf("<%.*s+0x%x>", length += printf("<%.*s+0x%x>",
sizeof(canonical_symbol->name), (int) sizeof(canonical_symbol->name),
canonical_symbol->name, canonical_symbol->name,
canonical_symbol->offset); canonical_symbol->offset);
if (verbose) if (verbose)

View File

@@ -140,14 +140,14 @@ typedef struct {
rtems_id id; rtems_id id;
rtems_name name; rtems_name name;
/* end of common portion */ /* end of common portion */
rtems_monitor_symbol_t create; rtems_monitor_symbol_t e_create;
rtems_monitor_symbol_t start; rtems_monitor_symbol_t e_start;
rtems_monitor_symbol_t restart; rtems_monitor_symbol_t e_restart;
rtems_monitor_symbol_t delete; rtems_monitor_symbol_t e_delete;
rtems_monitor_symbol_t tswitch; rtems_monitor_symbol_t e_tswitch;
rtems_monitor_symbol_t begin; rtems_monitor_symbol_t e_begin;
rtems_monitor_symbol_t exitted; rtems_monitor_symbol_t e_exitted;
rtems_monitor_symbol_t fatal; rtems_monitor_symbol_t e_fatal;
} rtems_monitor_extension_t; } rtems_monitor_extension_t;
/* /*

View File

@@ -128,10 +128,12 @@ void Stack_check_Initialize( void )
rtems_status_code status; rtems_status_code status;
Objects_Id id_ignored; Objects_Id id_ignored;
unsigned32 *p; unsigned32 *p;
#if 0
unsigned32 i; unsigned32 i;
unsigned32 class_index; unsigned32 class_index;
Thread_Control *the_thread; Thread_Control *the_thread;
Objects_Information *information; Objects_Information *information;
#endif
if (stack_check_initialized) if (stack_check_initialized)
return; return;
@@ -420,7 +422,11 @@ void Stack_check_Dump_threads_usage(
* Stack_check_Fatal_extension * Stack_check_Fatal_extension
*/ */
void Stack_check_Fatal_extension( unsigned32 status ) void Stack_check_Fatal_extension(
Internal_errors_Source source,
boolean is_internal,
unsigned32 status
)
{ {
if (status == 0) if (status == 0)
Stack_check_Dump_usage(); Stack_check_Dump_usage();
@@ -443,6 +449,7 @@ void Stack_check_Dump_usage( void )
if (stack_check_initialized == 0) if (stack_check_initialized == 0)
return; return;
printf("Stack usage by thread\n");
printf( printf(
" ID NAME LOW HIGH AVAILABLE USED\n" " ID NAME LOW HIGH AVAILABLE USED\n"
); );

View File

@@ -77,7 +77,9 @@ void Stack_check_Switch_extension(
*/ */
void Stack_check_Fatal_extension( void Stack_check_Fatal_extension(
unsigned32 Internal_errors_Source source,
boolean is_internal,
unsigned32 status
); );
/* /*

View File

@@ -14,12 +14,13 @@
* Division Incorporated makes no representations about the * Division Incorporated makes no representations about the
* suitability of this software for any purpose. * suitability of this software for any purpose.
* *
* $Id$ * cpu.c,v 1.7 1995/09/19 14:49:35 joel Exp
*/ */
#include <rtems/system.h> #include <rtems/system.h>
#include <rtems/score/isr.h> #include <rtems/fatal.h>
#include <rtems/score/wkspace.h> #include <rtems/core/isr.h>
#include <rtems/core/wkspace.h>
void hppa_external_interrupt_initialize(void); void hppa_external_interrupt_initialize(void);
void hppa_external_interrupt_enable(unsigned32); void hppa_external_interrupt_enable(unsigned32);
@@ -103,6 +104,20 @@ void _CPU_Initialize(
_CPU_Table = *cpu_table; _CPU_Table = *cpu_table;
} }
/*PAGE
*
* _CPU_ISR_Get_level
*/
unsigned32 _CPU_ISR_Get_level(void)
{
int level;
HPPA_ASM_SSM(0, level); /* change no bits; just get copy */
if (level & HPPA_PSW_I)
return 1;
return 0;
}
/*PAGE /*PAGE
* *
* _CPU_ISR_install_raw_handler * _CPU_ISR_install_raw_handler

View File

@@ -173,7 +173,7 @@ void _CPU_Signal_initialize( void )
void _CPU_Context_From_CPU_Init() void _CPU_Context_From_CPU_Init()
{ {
#if defined(hppa1_1) && defined(RTEMS_UNIXLIB) #if defined(hppa1_1) && defined(RTEMS_UNIXLIB_SETJMP)
/* /*
* 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.

View File

@@ -280,11 +280,11 @@ STATIC INLINE Heap_Block *_Heap_Block_at(
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
STATIC INLINE Heap_Block *_Heap_User_Block_at( STATIC INLINE Heap_Block *_Heap_User_block_at(
void *base void *base
); );

View File

@@ -94,11 +94,11 @@ STATIC INLINE Heap_Block *_Heap_Block_at(
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
STATIC INLINE Heap_Block *_Heap_User_Block_at( STATIC INLINE Heap_Block *_Heap_User_block_at(
void *base void *base
) )
{ {

View File

@@ -70,11 +70,11 @@
/*PAGE /*PAGE
* *
* _Heap_User_Block_at * _Heap_User_block_at
* *
*/ */
#define _Heap_User_Block_at( _base ) \ #define _Heap_User_block_at( _base ) \
_Heap_Block_at( \ _Heap_Block_at( \
(_base), \ (_base), \
-*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \ -*(((unsigned32 *) (_base)) - 1) + -HEAP_BLOCK_USED_OVERHEAD \

View File

@@ -301,7 +301,7 @@ boolean _Heap_Size_of_user_area(
Heap_Block *next_block; Heap_Block *next_block;
unsigned32 the_size; unsigned32 the_size;
the_block = _Heap_User_Block_at( starting_address ); the_block = _Heap_User_block_at( starting_address );
if ( !_Heap_Is_block_in( the_heap, the_block ) || if ( !_Heap_Is_block_in( the_heap, the_block ) ||
_Heap_Is_block_free( the_block ) ) _Heap_Is_block_free( the_block ) )
@@ -346,7 +346,7 @@ boolean _Heap_Free(
Heap_Block *temporary_block; Heap_Block *temporary_block;
unsigned32 the_size; unsigned32 the_size;
the_block = _Heap_User_Block_at( starting_address ); the_block = _Heap_User_block_at( starting_address );
if ( !_Heap_Is_block_in( the_heap, the_block ) || if ( !_Heap_Is_block_in( the_heap, the_block ) ||
_Heap_Is_block_free( the_block ) ) { _Heap_Is_block_free( the_block ) ) {
@@ -430,6 +430,8 @@ void _Heap_Walk(
Heap_Block *the_block = 0; /* avoid warnings */ Heap_Block *the_block = 0; /* avoid warnings */
Heap_Block *next_block = 0; /* avoid warnings */ Heap_Block *next_block = 0; /* avoid warnings */
int notdone = 1; int notdone = 1;
int error = 0;
int passes = 0;
/* /*
* We don't want to allow walking the heap until we have * We don't want to allow walking the heap until we have
@@ -455,9 +457,14 @@ void _Heap_Walk(
if (the_block->back_flag != HEAP_DUMMY_FLAG) { if (the_block->back_flag != HEAP_DUMMY_FLAG) {
printf("PASS: %d Back flag of 1st block isn't HEAP_DUMMY_FLAG\n", source); printf("PASS: %d Back flag of 1st block isn't HEAP_DUMMY_FLAG\n", source);
error = 1;
} }
while (notdone) { while (notdone) {
passes++;
if (error && (passes > 10))
abort();
if (do_dump == TRUE) { if (do_dump == TRUE) {
printf("PASS: %d Block @ 0x%p Back %d, Front %d", printf("PASS: %d Block @ 0x%p Back %d, Front %d",
source, the_block, source, the_block,
@@ -477,6 +484,7 @@ void _Heap_Walk(
if ( the_block->front_flag != HEAP_DUMMY_FLAG ) { if ( the_block->front_flag != HEAP_DUMMY_FLAG ) {
next_block = _Heap_Next_block(the_block); next_block = _Heap_Next_block(the_block);
if ( the_block->front_flag != next_block->back_flag ) { if ( the_block->front_flag != next_block->back_flag ) {
error = 1;
printf("PASS: %d Front and back flags don't match\n", source); printf("PASS: %d Front and back flags don't match\n", source);
printf(" Current Block: Back - %d, Front - %d", printf(" Current Block: Back - %d, Front - %d",
the_block->back_flag, the_block->front_flag); the_block->back_flag, the_block->front_flag);
@@ -510,4 +518,7 @@ void _Heap_Walk(
else else
the_block = next_block; the_block = next_block;
} }
if (error)
abort();
} }

View File

@@ -29,7 +29,6 @@
#include <rtems.h> #include <rtems.h>
#include <stdio.h> #include <stdio.h>
#include <libcsupport.h>
#include <iostream.h> #include <iostream.h>
extern "C" { extern "C" {
@@ -128,7 +127,7 @@ cdtest(void)
// in many implementations in order to get global constructors // in many implementations in order to get global constructors
// run. // run.
// //
// Ref: c/src/lib/libbsp/hppa1_1/simhppa/startup/bspstart.c // Ref: c/src/lib/libbsp/hppa1_1/pxfl/startup/bspstart.c
// //

View File

@@ -26,7 +26,6 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <libcsupport.h>
#define FOREVER 1 /* infinite loop */ #define FOREVER 1 /* infinite loop */
@@ -95,8 +94,6 @@ extern "C" {
putchar( '\n' ); \ putchar( '\n' ); \
} }
#define put_buffer( _buffer ) XYZ( _buffer )
#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \ #define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
{ (TB)->year = YR; \ { (TB)->year = YR; \
(TB)->month = MON; \ (TB)->month = MON; \

View File

@@ -86,7 +86,7 @@ void error(int errn, ...);
#define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */ #define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */
#define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */ #define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */
#define stol(p) strtol(p, (char **) NULL, 0) #define stol(p) strtoul(p, (char **) NULL, 0)
int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm); int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm);
int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm); int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm);

View File

@@ -86,7 +86,7 @@ void error(int errn, ...);
#define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */ #define ERR_ABORT (ERR_ERRNO / 4) /* error is fatal; abort */
#define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */ #define ERR_MASK (ERR_ERRNO | ERR_FATAL | ERR_ABORT) /* all */
#define stol(p) strtol(p, (char **) NULL, 0) #define stol(p) strtoul(p, (char **) NULL, 0)
int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm); int unhex(FILE *ifp, char *inm, FILE *ofp, char *onm);
int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm); int convert_Intel_records(FILE *ifp, char *inm, FILE *ofp, char *onm);

View File

@@ -1,5 +1,5 @@
/* /*
* @(#)genoffsets.c 1.5 - 95/05/16 * @(#)genoffsets.c 1.7 - 95/09/25
* *
* *
* genoffsets.c * genoffsets.c
@@ -82,7 +82,7 @@ printf(
"\n" \ "\n" \
); );
#if defined(hpux) && defined(__hppa__) #if defined(__hpux__) && defined(__hppa__)
/* /*
* Offsets of elements in the Context_control structure. * Offsets of elements in the Context_control structure.