diff options
Diffstat (limited to 'c/src/exec/score')
153 files changed, 4297 insertions, 1849 deletions
diff --git a/c/src/exec/score/cpu/hppa1.1/cpu.c b/c/src/exec/score/cpu/hppa1.1/cpu.c index 437996a78d..6cb6347151 100644 --- a/c/src/exec/score/cpu/hppa1.1/cpu.c +++ b/c/src/exec/score/cpu/hppa1.1/cpu.c @@ -19,11 +19,10 @@ #include <rtems/system.h> #include <rtems/fatal.h> -#include <rtems/isr.h> -#include <rtems/intr.h> -#include <rtems/wkspace.h> +#include <rtems/core/isr.h> +#include <rtems/core/wkspace.h> -rtems_status_code hppa_external_interrupt_initialize(void); +void hppa_external_interrupt_initialize(void); void hppa_external_interrupt_enable(unsigned32); void hppa_external_interrupt_disable(unsigned32); void hppa_external_interrupt(unsigned32, CPU_Interrupt_frame *); @@ -73,9 +72,6 @@ void _CPU_Initialize( extern void IVA_Table(void); - if ( cpu_table == NULL ) - rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED ); - /* * XXX; need to setup fpsr smarter perhaps */ @@ -194,7 +190,7 @@ void _CPU_ISR_install_vector( * called by bsp_start() */ -rtems_status_code +void hppa_external_interrupt_initialize(void) { rtems_isr_entry ignore; @@ -207,8 +203,6 @@ hppa_external_interrupt_initialize(void) /* install the external interrupt handler */ rtems_interrupt_catch((rtems_isr_entry) hppa_external_interrupt, HPPA_INTERRUPT_EXTERNAL_INTERRUPT, &ignore) ; - - return RTEMS_SUCCESSFUL; } /* diff --git a/c/src/exec/score/cpu/hppa1.1/cpu.h b/c/src/exec/score/cpu/hppa1.1/cpu.h index 3d330e09e5..e1f6cbfa48 100644 --- a/c/src/exec/score/cpu/hppa1.1/cpu.h +++ b/c/src/exec/score/cpu/hppa1.1/cpu.h @@ -30,9 +30,9 @@ extern "C" { #endif -#include <rtems/hppa.h> /* pick up machine definitions */ +#include <rtems/core/hppa.h> /* pick up machine definitions */ #ifndef ASM -#include <rtems/hppatypes.h> +#include <rtems/core/hppatypes.h> #endif /* conditional compilation parameters */ diff --git a/c/src/exec/score/cpu/hppa1.1/cpu_asm.s b/c/src/exec/score/cpu/hppa1.1/cpu_asm.s index acb6e589fd..229efed42c 100644 --- a/c/src/exec/score/cpu/hppa1.1/cpu_asm.s +++ b/c/src/exec/score/cpu/hppa1.1/cpu_asm.s @@ -27,11 +27,11 @@ * $Id$ # -#include <rtems/hppa.h> -#include <rtems/cpu_asm.h> -#include <rtems/cpu.h> +#include <rtems/core/hppa.h> +#include <rtems/core/cpu_asm.h> +#include <rtems/core/cpu.h> -#include <offsets.h> +#include <rtems/core/offsets.h> .SPACE $PRIVATE$ .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31 diff --git a/c/src/exec/score/cpu/hppa1.1/rtems.s b/c/src/exec/score/cpu/hppa1.1/rtems.s index 84ffadd856..0e9305644e 100644 --- a/c/src/exec/score/cpu/hppa1.1/rtems.s +++ b/c/src/exec/score/cpu/hppa1.1/rtems.s @@ -15,7 +15,7 @@ */ #include <rtems/hppa.h> -#include <rtems/cpu_asm.h> +#include <rtems/core/cpu_asm.h> .SPACE $PRIVATE$ .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31 diff --git a/c/src/exec/score/cpu/i386/asm.h b/c/src/exec/score/cpu/i386/asm.h index adf92f935a..aac1ba9dbe 100644 --- a/c/src/exec/score/cpu/i386/asm.h +++ b/c/src/exec/score/cpu/i386/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include <rtems/i386.h> +#include <rtems/core/i386.h> /* * Recent versions of GNU cpp define variables which indicate the diff --git a/c/src/exec/score/cpu/i386/cpu.c b/c/src/exec/score/cpu/i386/cpu.c index d1ceaba88a..446515d6f9 100644 --- a/c/src/exec/score/cpu/i386/cpu.c +++ b/c/src/exec/score/cpu/i386/cpu.c @@ -15,8 +15,8 @@ #include <rtems/system.h> #include <rtems/fatal.h> -#include <rtems/isr.h> -#include <rtems/wkspace.h> +#include <rtems/core/isr.h> +#include <rtems/core/wkspace.h> /* _CPU_Initialize * @@ -36,9 +36,6 @@ void _CPU_Initialize( register unsigned16 fp_status asm ("ax"); register unsigned8 *fp_context; - if ( cpu_table == NULL ) - rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED ); - _CPU_Table = *cpu_table; /* @@ -69,6 +66,20 @@ void _CPU_Initialize( /*PAGE * + * _CPU_ISR_Get_level + */ + +unsigned32 _CPU_ISR_Get_level( void ) +{ + unsigned32 level; + + i386_get_interrupt_level( level ); + + return level; +} + +/*PAGE + * * _CPU_ISR_install_raw_handler */ diff --git a/c/src/exec/score/cpu/i386/cpu.h b/c/src/exec/score/cpu/i386/cpu.h index 2af0096fc6..f3793cd443 100644 --- a/c/src/exec/score/cpu/i386/cpu.h +++ b/c/src/exec/score/cpu/i386/cpu.h @@ -22,9 +22,9 @@ extern "C" { #endif #ifndef ASM -#include <rtems/i386types.h> +#include <rtems/core/i386types.h> #endif -#include <rtems/i386.h> +#include <rtems/core/i386.h> /* conditional compilation parameters */ @@ -119,9 +119,9 @@ typedef struct { /* variables */ -EXTERN unsigned8 _CPU_Null_fp_context[ CPU_CONTEXT_FP_SIZE ]; -EXTERN void *_CPU_Interrupt_stack_low; -EXTERN void *_CPU_Interrupt_stack_high; +EXTERN Context_Control_fp _CPU_Null_fp_context; +EXTERN void *_CPU_Interrupt_stack_low; +EXTERN void *_CPU_Interrupt_stack_high; /* constants */ @@ -192,6 +192,8 @@ EXTERN void *_CPU_Interrupt_stack_high; else asm volatile ( "sti" ); \ } +unsigned32 _CPU_ISR_Get_level( void ); + /* end of ISR handler macros */ /* diff --git a/c/src/exec/score/cpu/i386/i386.h b/c/src/exec/score/cpu/i386/i386.h index 3ebde48ed3..d43669ba53 100644 --- a/c/src/exec/score/cpu/i386/i386.h +++ b/c/src/exec/score/cpu/i386/i386.h @@ -166,6 +166,18 @@ typedef struct { ); \ } +#define i386_get_interrupt_level( _level ) \ + do { \ + register unsigned32 _eflags = 0; \ + \ + asm volatile ( "push %0 ; \ + popf " \ + : "=r" ((_eflags)) : "0" ((_eflags)) \ + ); \ + \ + _level = (_eflags & 0x0200) ? 0 : 1; \ + } while (0) + /* * The following routine swaps the endian format of an unsigned int. * It must be static so it can be referenced indirectly. diff --git a/c/src/exec/score/cpu/i960/asm.h b/c/src/exec/score/cpu/i960/asm.h index e8fc986402..73a8b3a641 100644 --- a/c/src/exec/score/cpu/i960/asm.h +++ b/c/src/exec/score/cpu/i960/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include <rtems/i960.h> +#include <rtems/core/i960.h> /* * Recent versions of GNU cpp define variables which indicate the diff --git a/c/src/exec/score/cpu/i960/cpu.c b/c/src/exec/score/cpu/i960/cpu.c index d5acebd225..ec4613c4cf 100644 --- a/c/src/exec/score/cpu/i960/cpu.c +++ b/c/src/exec/score/cpu/i960/cpu.c @@ -21,7 +21,7 @@ #include <rtems/system.h> #include <rtems/fatal.h> -#include <rtems/isr.h> +#include <rtems/core/isr.h> /* _CPU_Initialize * @@ -40,15 +40,26 @@ void _CPU_Initialize( ) { - if ( cpu_table == NULL ) - rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED ); - _CPU_Table = *cpu_table; } /*PAGE * + * _CPU_ISR_Get_level + */ + +unsigned32 _CPU_ISR_Get_level( void ) +{ + unsigned32 level; + + i960_get_interrupt_level( level ); + + return level; +} + +/*PAGE + * * _CPU_ISR_install_raw_handler */ diff --git a/c/src/exec/score/cpu/i960/cpu.h b/c/src/exec/score/cpu/i960/cpu.h index 4e8e82e9de..3c4cb98ec8 100644 --- a/c/src/exec/score/cpu/i960/cpu.h +++ b/c/src/exec/score/cpu/i960/cpu.h @@ -23,9 +23,9 @@ extern "C" { #pragma align 4 /* for GNU C structure alignment */ -#include <rtems/i960.h> +#include <rtems/core/i960.h> #ifndef ASM -#include <rtems/i960types.h> +#include <rtems/core/i960types.h> #endif #define CPU_INLINE_ENABLE_DISPATCH FALSE @@ -237,6 +237,8 @@ EXTERN void *_CPU_Interrupt_stack_high; ); \ } +unsigned32 _CPU_ISR_Get_level( void ); + /* ISR handler section macros */ /* diff --git a/c/src/exec/score/cpu/i960/i960.h b/c/src/exec/score/cpu/i960/i960.h index 53b99f469a..5112fd58c8 100644 --- a/c/src/exec/score/cpu/i960/i960.h +++ b/c/src/exec/score/cpu/i960/i960.h @@ -169,6 +169,13 @@ typedef struct { : "0" (_mask), "1" ((oldlevel)) ); \ } +#define i960_get_interrupt_level( _level ) \ + { \ + i960_disable_interrupts( _level ); \ + i960_enable_interrupts( _level ); \ + (_level) = ((_level) & 0x1f0000) >> 16; \ + } while ( 0 ) + #define i960_atomic_modify( mask, addr, prev ) \ { register unsigned int _mask = (mask); \ register unsigned int *_addr = (unsigned int *)(addr); \ @@ -199,9 +206,8 @@ typedef struct { #define i960_clear_intr( xint ) \ { register unsigned int _xint=(xint); \ - asm volatile( "loop_til_cleared: - clrbit %0,sf0,sf0 ; \ - bbs %0,sf0,loop_til_cleared" \ +asm volatile( "loop_til_cleared: clrbit %0,sf0,sf0 ; \ + bbs %0,sf0, loop_til_cleared" \ : "=d" (_xint) : "0" (_xint) ); \ } diff --git a/c/src/exec/score/cpu/m68k/asm.h b/c/src/exec/score/cpu/m68k/asm.h index 58bb04bdf9..7a25b6c298 100644 --- a/c/src/exec/score/cpu/m68k/asm.h +++ b/c/src/exec/score/cpu/m68k/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include <rtems/m68k.h> +#include <rtems/core/m68k.h> /* * Recent versions of GNU cpp define variables which indicate the diff --git a/c/src/exec/score/cpu/m68k/cpu.c b/c/src/exec/score/cpu/m68k/cpu.c index a97698372a..fdba64bffe 100644 --- a/c/src/exec/score/cpu/m68k/cpu.c +++ b/c/src/exec/score/cpu/m68k/cpu.c @@ -14,7 +14,7 @@ #include <rtems/system.h> #include <rtems/fatal.h> -#include <rtems/isr.h> +#include <rtems/core/isr.h> /* _CPU_Initialize * @@ -33,15 +33,26 @@ void _CPU_Initialize( ) { - if ( cpu_table == NULL ) - rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED ); - _CPU_Table = *cpu_table; } /*PAGE * + * _CPU_ISR_Get_level + */ + +unsigned32 _CPU_ISR_Get_level( void ) +{ + unsigned32 level; + + m68k_get_interrupt_level( level ); + + return level; +} + +/*PAGE + * * _CPU_ISR_install_raw_handler */ diff --git a/c/src/exec/score/cpu/m68k/cpu.h b/c/src/exec/score/cpu/m68k/cpu.h index 566e479f3a..8379d47a00 100644 --- a/c/src/exec/score/cpu/m68k/cpu.h +++ b/c/src/exec/score/cpu/m68k/cpu.h @@ -30,9 +30,9 @@ extern "C" { #define NO_UNINITIALIZED_WARNINGS -#include <rtems/m68k.h> +#include <rtems/core/m68k.h> #ifndef ASM -#include <rtems/m68ktypes.h> +#include <rtems/core/m68ktypes.h> #endif /* conditional compilation parameters */ @@ -222,6 +222,8 @@ EXTERN void *_CPU_Interrupt_stack_high; #define _CPU_ISR_Set_level( _newlevel ) \ m68k_set_interrupt_level( _newlevel ) +unsigned32 _CPU_ISR_Get_level( void ); + /* end of ISR handler macros */ /* diff --git a/c/src/exec/score/cpu/m68k/m68k.h b/c/src/exec/score/cpu/m68k/m68k.h index b86db286cb..a2e0df6a25 100644 --- a/c/src/exec/score/cpu/m68k/m68k.h +++ b/c/src/exec/score/cpu/m68k/m68k.h @@ -196,6 +196,17 @@ extern "C" { ); \ } +#define m68k_get_interrupt_level( _level ) \ + do { \ + register unsigned32 _tmpsr = 0; \ + \ + asm volatile( "movw %%sr,%0" \ + : "=d" (_tmpsr) : "0" (_tmpsr) \ + ); \ + \ + _level = (_tmpsr & 0x0700) >> 8; \ + } while (0) + #define m68k_set_interrupt_level( _newlevel ) \ { \ register unsigned32 _tmpsr = 0; \ diff --git a/c/src/exec/score/cpu/no_cpu/asm.h b/c/src/exec/score/cpu/no_cpu/asm.h index 97464d5b3a..ca0ff95e35 100644 --- a/c/src/exec/score/cpu/no_cpu/asm.h +++ b/c/src/exec/score/cpu/no_cpu/asm.h @@ -31,7 +31,7 @@ */ #define ASM -#include <rtems/no_cpu.h> +#include <rtems/core/no_cpu.h> /* * Recent versions of GNU cpp define variables which indicate the diff --git a/c/src/exec/score/cpu/no_cpu/cpu.c b/c/src/exec/score/cpu/no_cpu/cpu.c index f95c435eae..c7e7cbe693 100644 --- a/c/src/exec/score/cpu/no_cpu/cpu.c +++ b/c/src/exec/score/cpu/no_cpu/cpu.c @@ -15,8 +15,8 @@ #include <rtems/system.h> #include <rtems/fatal.h> -#include <rtems/isr.h> -#include <rtems/wkspace.h> +#include <rtems/core/isr.h> +#include <rtems/core/wkspace.h> /* _CPU_Initialize * @@ -33,9 +33,6 @@ void _CPU_Initialize( void (*thread_dispatch) /* ignored on this CPU */ ) { - if ( cpu_table == NULL ) - rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED ); - /* * The thread_dispatch argument is the address of the entry point * for the routine called at the end of an ISR once it has been @@ -63,6 +60,18 @@ void _CPU_Initialize( /*PAGE * + * _CPU_ISR_Get_level + */ + +unsigned32 _CPU_ISR_Get_level( void ) +{ + /* + * This routine returns the current interrupt level. + */ +} + +/*PAGE + * * _CPU_ISR_install_raw_handler */ diff --git a/c/src/exec/score/cpu/no_cpu/cpu.h b/c/src/exec/score/cpu/no_cpu/cpu.h index 29a6960ea2..7242ebc041 100644 --- a/c/src/exec/score/cpu/no_cpu/cpu.h +++ b/c/src/exec/score/cpu/no_cpu/cpu.h @@ -21,9 +21,9 @@ extern "C" { #endif -#include <rtems/no_cpu.h> /* pick up machine definitions */ +#include <rtems/core/no_cpu.h> /* pick up machine definitions */ #ifndef ASM -#include <rtems/no_cputypes.h> +#include <rtems/core/no_cputypes.h> #endif /* conditional compilation parameters */ diff --git a/c/src/exec/score/cpu/no_cpu/cpu_asm.c b/c/src/exec/score/cpu/no_cpu/cpu_asm.c index c0cf3b5127..0d7622d15f 100644 --- a/c/src/exec/score/cpu/no_cpu/cpu_asm.c +++ b/c/src/exec/score/cpu/no_cpu/cpu_asm.c @@ -24,7 +24,7 @@ */ #include <rtems/system.h> -#include <rtems/cpu.h> +#include <rtems/core/cpu.h> /* #include "cpu_asm.h> */ /* diff --git a/c/src/exec/score/cpu/no_cpu/cpu_asm.h b/c/src/exec/score/cpu/no_cpu/cpu_asm.h index 0f4154a453..50bc256e06 100644 --- a/c/src/exec/score/cpu/no_cpu/cpu_asm.h +++ b/c/src/exec/score/cpu/no_cpu/cpu_asm.h @@ -21,7 +21,7 @@ /* pull in the generated offsets */ -#include <offsets.h> +#include <rtems/core/offsets.h> /* * Hardware General Registers diff --git a/c/src/exec/score/cpu/no_cpu/rtems.c b/c/src/exec/score/cpu/no_cpu/rtems.c index 5415ae9852..0d15381046 100644 --- a/c/src/exec/score/cpu/no_cpu/rtems.c +++ b/c/src/exec/score/cpu/no_cpu/rtems.c @@ -22,7 +22,7 @@ */ #include <rtems/system.h> -#include <rtems/cpu.h> +#include <rtems/core/cpu.h> /* #include "asm.h> */ /* diff --git a/c/src/exec/score/cpu/powerpc/cpu.c b/c/src/exec/score/cpu/powerpc/cpu.c index ab358a2490..336f1e1aef 100644 --- a/c/src/exec/score/cpu/powerpc/cpu.c +++ b/c/src/exec/score/cpu/powerpc/cpu.c @@ -30,15 +30,17 @@ #include <rtems/system.h> #include <rtems/fatal.h> -#include <rtems/isr.h> -#include <rtems/context.h> -#include <rtems/thread.h> -#include <rtems/wkspace.h> +#include <rtems/core/isr.h> +#include <rtems/core/context.h> +#include <rtems/core/thread.h> +#include <rtems/core/wkspace.h> /* * These are for testing purposes. */ +/* #define Testing +*/ #ifdef Testing static unsigned32 msr; @@ -119,9 +121,6 @@ void _CPU_Initialize( } #endif - if ( cpu_table == NULL ) - rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED ); - if ( cpu_table->spurious_handler ) handler = (proc_ptr)cpu_table->spurious_handler; @@ -164,9 +163,11 @@ void _CPU_ISR_install_vector( * be used by the _ISR_Handler so the user gets control. */ - _ISR_Vector_table[ vector ] = new_handler ? (rtems_isr_entry)new_handler : - _CPU_Table.spurious_handler ? (rtems_isr_entry)_CPU_Table.spurious_handler : - (rtems_isr_entry)ppc_spurious; + _ISR_Vector_table[ vector ] = + (new_handler) ? (ISR_Handler_entry) new_handler : + ((_CPU_Table.spurious_handler) ? + (ISR_Handler_entry) _CPU_Table.spurious_handler : + (ISR_Handler_entry) ppc_spurious); } /*PAGE diff --git a/c/src/exec/score/cpu/powerpc/cpu.h b/c/src/exec/score/cpu/powerpc/cpu.h index 82cad518e8..fd44f5ee8e 100644 --- a/c/src/exec/score/cpu/powerpc/cpu.h +++ b/c/src/exec/score/cpu/powerpc/cpu.h @@ -37,11 +37,11 @@ extern "C" { #endif -#include <rtems/ppc.h> /* pick up machine definitions */ +#include <rtems/core/ppc.h> /* pick up machine definitions */ #ifndef ASM struct CPU_Interrupt_frame; -#include <rtems/ppctypes.h> +#include <rtems/core/ppctypes.h> #endif /* conditional compilation parameters */ diff --git a/c/src/exec/score/cpu/unix/cpu.c b/c/src/exec/score/cpu/unix/cpu.c index 736b7c4c7f..339bb2a3ce 100644 --- a/c/src/exec/score/cpu/unix/cpu.c +++ b/c/src/exec/score/cpu/unix/cpu.c @@ -17,7 +17,7 @@ */ #include <rtems/system.h> -#include <rtems/isr.h> +#include <rtems/core/isr.h> #include <stdio.h> #include <stdlib.h> @@ -186,6 +186,28 @@ void _CPU_Context_From_CPU_Init() } +/*PAGE + * + * _CPU_ISR_Get_level + */ + +unsigned32 _CPU_ISR_Get_level( void ) +{ + sigset_t sigset; + + sigprocmask( 0, 0, &sigset ); + + /* + * This is an educated guess based on ONLY ONE of the signals we + * disable/enable to mask ISRs. + */ + + if ( sigismember( &sigset, SIGUSR1 ) ) + return 1; + else + return 0; +} + /* _CPU_Initialize * * This routine performs processor dependent initialization. @@ -198,12 +220,9 @@ void _CPU_Context_From_CPU_Init() void _CPU_Initialize( rtems_cpu_table *cpu_table, - void (*thread_dispatch) /* ignored on this CPU */ + void (*thread_dispatch) /* ignored on this CPU */ ) { - if ( cpu_table == NULL ) - _CPU_Fatal_halt( RTEMS_NOT_CONFIGURED ); - /* * The thread_dispatch argument is the address of the entry point * for the routine called at the end of an ISR once it has been diff --git a/c/src/exec/score/cpu/unix/cpu.h b/c/src/exec/score/cpu/unix/cpu.h index ee7239bc89..f0d583651e 100644 --- a/c/src/exec/score/cpu/unix/cpu.h +++ b/c/src/exec/score/cpu/unix/cpu.h @@ -26,9 +26,9 @@ extern "C" { #endif -#include <rtems/unix.h> +#include <rtems/core/unix.h> #ifndef ASM -#include <rtems/unixtypes.h> +#include <rtems/core/unixtypes.h> #endif #if defined(solaris2) @@ -667,6 +667,8 @@ void _CPU_ISR_Enable(unsigned32 level); else _CPU_ISR_Enable( 1 ); \ } +unsigned32 _CPU_ISR_Get_level( void ); + /* end of ISR handler macros */ /* Context handler macros */ diff --git a/c/src/exec/score/headers/address.h b/c/src/exec/score/headers/address.h index 0abd113f63..4877206801 100644 --- a/c/src/exec/score/headers/address.h +++ b/c/src/exec/score/headers/address.h @@ -52,21 +52,6 @@ STATIC INLINE void *_Addresses_Subtract_offset( ); /* - * _Addresses_Add - * - * DESCRIPTION: - * - * This function is used to add two addresses. It returns the - * resulting address. This address is typically converted to an - * access type before being used further. - */ - -STATIC INLINE void *_Addresses_Add ( - void *left, - void *right -); - -/* * _Addresses_Subtract * * DESCRIPTION: @@ -112,7 +97,7 @@ STATIC INLINE boolean _Addresses_Is_in_range ( void *limit ); -#include <rtems/address.inl> +#include <rtems/core/address.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/chain.h b/c/src/exec/score/headers/chain.h index 06cc47cc65..35ac4dfa80 100644 --- a/c/src/exec/score/headers/chain.h +++ b/c/src/exec/score/headers/chain.h @@ -21,7 +21,7 @@ extern "C" { #endif -#include <rtems/address.h> +#include <rtems/core/address.h> /* * This is used to manage each element (node) which is placed @@ -422,7 +422,7 @@ STATIC INLINE boolean _Chain_Is_null_node( Chain_Node *the_node ); -#include <rtems/chain.inl> +#include <rtems/core/chain.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/context.h b/c/src/exec/score/headers/context.h index 9b8ee92b04..58e497ae88 100644 --- a/c/src/exec/score/headers/context.h +++ b/c/src/exec/score/headers/context.h @@ -20,7 +20,7 @@ extern "C" { #endif -#include <rtems/cpu.h> +#include <rtems/core/cpu.h> /* * The following constant defines the number of bytes required diff --git a/c/src/exec/score/headers/coremutex.h b/c/src/exec/score/headers/coremutex.h new file mode 100644 index 0000000000..0682bbc1ea --- /dev/null +++ b/c/src/exec/score/headers/coremutex.h @@ -0,0 +1,247 @@ +/* mutex.h + * + * This include file contains all the constants and structures associated + * with the Mutex Handler. A mutex is an enhanced version of the standard + * Dijkstra binary semaphore used to provide synchronization and mutual + * exclusion capabilities. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __RTEMS_CORE_MUTEX_h +#define __RTEMS_CORE_MUTEX_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/priority.h> +#include <rtems/core/watchdog.h> + +/* + * The following type defines the callout which the API provides + * to support global/multiprocessor operations on mutexes. + */ + +typedef void ( *CORE_mutex_API_mp_support_callout )( + Thread_Control *, + Objects_Id + ); + +/* + * Blocking disciplines for a mutex. + */ + +typedef enum { + CORE_MUTEX_DISCIPLINES_FIFO, + CORE_MUTEX_DISCIPLINES_PRIORITY, + CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT, + CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING +} CORE_mutex_Disciplines; + +/* + * Mutex handler return statuses. + */ + +typedef enum { + CORE_MUTEX_STATUS_SUCCESSFUL, + CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT, + CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED, + CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE, + CORE_MUTEX_WAS_DELETED, + CORE_MUTEX_TIMEOUT +} CORE_mutex_Status; + +/* + * Locked and unlocked values + */ + +#define CORE_MUTEX_UNLOCKED 1 +#define CORE_MUTEX_LOCKED 0 + +/* + * The following defines the control block used to manage the + * attributes of each mutex. + */ + +typedef struct { + boolean allow_nesting; + CORE_mutex_Disciplines discipline; + Priority_Control priority_ceiling; +} CORE_mutex_Attributes; + +/* + * The following defines the control block used to manage each mutex. + */ + +typedef struct { + Thread_queue_Control Wait_queue; + CORE_mutex_Attributes Attributes; + unsigned32 lock; + unsigned32 nest_count; + Thread_Control *holder; + Objects_Id holder_id; +} CORE_mutex_Control; + +/* + * _CORE_mutex_Initialize + * + * DESCRIPTION: + * + * This routine initializes the mutex based on the parameters passed. + */ + +void _CORE_mutex_Initialize( + CORE_mutex_Control *the_mutex, + Objects_Classes the_class, + CORE_mutex_Attributes *the_mutex_attributes, + unsigned32 initial_lock, + Thread_queue_Extract_callout proxy_extract_callout +); + +/* + * _CORE_mutex_Seize + * + * DESCRIPTION: + * + * This routine attempts to receive a unit from the_mutex. + * If a unit is available or if the wait flag is FALSE, then the routine + * returns. Otherwise, the calling task is blocked until a unit becomes + * available. + */ + +void _CORE_mutex_Seize( + CORE_mutex_Control *the_mutex, + Objects_Id id, + boolean wait, + Watchdog_Interval timeout +); + +/* + * _CORE_mutex_Surrender + * + * DESCRIPTION: + * + * This routine frees a unit to the mutex. If a task was blocked waiting for + * a unit from this mutex, then that task will be readied and the unit + * given to that task. Otherwise, the unit will be returned to the mutex. + */ + +CORE_mutex_Status _CORE_mutex_Surrender( + CORE_mutex_Control *the_mutex, + Objects_Id id, + CORE_mutex_API_mp_support_callout api_mutex_mp_support +); + +/* + * _CORE_mutex_Flush + * + * DESCRIPTION: + * + * This routine assists in the deletion of a mutex by flushing the associated + * wait queue. + */ + +void _CORE_mutex_Flush( + CORE_mutex_Control *the_mutex, + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status +); + +/* + * _CORE_mutex_Is_locked + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex specified is locked and FALSE + * otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_locked( + CORE_mutex_Control *the_mutex +); + +/* + * _CORE_mutex_Is_fifo + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is FIFO and FALSE + * otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_fifo( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_priority + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is PRIORITY and + * FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_inherit_priority + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is + * INHERIT_PRIORITY and FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_inherit_priority( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_priority_ceiling + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is + * PRIORITY_CEILING and FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority_ceiling( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_nesting_allowed + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex allows a task to obtain a + * semaphore more than once and nest. + */ + +STATIC INLINE boolean _CORE_mutex_Is_nesting_allowed( + CORE_mutex_Attributes *the_attribute +); + +#include <rtems/core/coremutex.inl> + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ + diff --git a/c/src/exec/score/headers/coresem.h b/c/src/exec/score/headers/coresem.h new file mode 100644 index 0000000000..0fcd8cd0b9 --- /dev/null +++ b/c/src/exec/score/headers/coresem.h @@ -0,0 +1,179 @@ +/* core_sem.h + * + * This include file contains all the constants and structures associated + * with the Counting Semaphore Handler. A counting semaphore is the + * standard Dijkstra binary semaphore used to provide synchronization + * and mutual exclusion capabilities. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __RTEMS_CORE_COUNTING_SEMAPHORE_h +#define __RTEMS_CORE_COUNTING_SEMAPHORE_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/priority.h> +#include <rtems/core/watchdog.h> + +/* + * The following type defines the callout which the API provides + * to support global/multiprocessor operations on semaphores. + */ + +typedef void ( *CORE_semaphore_API_mp_support_callout )( + Thread_Control *, + Objects_Id + ); + +/* + * Blocking disciplines for a semaphore. + */ + +typedef enum { + CORE_SEMAPHORE_DISCIPLINES_FIFO, + CORE_SEMAPHORE_DISCIPLINES_PRIORITY +} CORE_semaphore_Disciplines; + +/* + * Core Semaphore handler return statuses. + */ + +typedef enum { + CORE_SEMAPHORE_STATUS_SUCCESSFUL, + CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT, + CORE_SEMAPHORE_WAS_DELETED, + CORE_SEMAPHORE_TIMEOUT +} CORE_semaphore_Status; + +/* + * The following defines the control block used to manage the + * attributes of each semaphore. + */ + +typedef struct { + CORE_semaphore_Disciplines discipline; +} CORE_semaphore_Attributes; + +/* + * The following defines the control block used to manage each + * counting semaphore. + */ + +typedef struct { + Thread_queue_Control Wait_queue; + CORE_semaphore_Attributes Attributes; + unsigned32 count; +} CORE_semaphore_Control; + +/* + * _CORE_semaphore_Initialize + * + * DESCRIPTION: + * + * This routine initializes the semaphore based on the parameters passed. + */ + +void _CORE_semaphore_Initialize( + CORE_semaphore_Control *the_semaphore, + Objects_Classes the_class, + CORE_semaphore_Attributes *the_semaphore_attributes, + unsigned32 initial_value, + Thread_queue_Extract_callout proxy_extract_callout +); + +/* + * _CORE_semaphore_Seize + * + * DESCRIPTION: + * + * This routine attempts to receive a unit from the_semaphore. + * If a unit is available or if the wait flag is FALSE, then the routine + * returns. Otherwise, the calling task is blocked until a unit becomes + * available. + */ + +void _CORE_semaphore_Seize( + CORE_semaphore_Control *the_semaphore, + Objects_Id id, + boolean wait, + Watchdog_Interval timeout +); + +/* + * _CORE_semaphore_Surrender + * + * DESCRIPTION: + * + * This routine frees a unit to the semaphore. If a task was blocked waiting + * for a unit from this semaphore, then that task will be readied and the unit + * given to that task. Otherwise, the unit will be returned to the semaphore. + */ + +CORE_semaphore_Status _CORE_semaphore_Surrender( + CORE_semaphore_Control *the_semaphore, + Objects_Id id, + CORE_semaphore_API_mp_support_callout api_semaphore_mp_support +); + +/* + * _CORE_semaphore_Flush + * + * DESCRIPTION: + * + * This routine assists in the deletion of a semaphore by flushing the + * associated wait queue. + */ + +void _CORE_semaphore_Flush( + CORE_semaphore_Control *the_semaphore, + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status +); + +/* + * _CORE_semaphore_Get_count + * + * DESCRIPTION: + * + * This routine returns the current count associated with the semaphore. + */ + +STATIC INLINE unsigned32 _CORE_semaphore_Get_count( + CORE_semaphore_Control *the_semaphore +); + +/* + * _CORE_semaphore_Is_priority + * + * DESCRIPTION: + * + * This function returns TRUE if the priority attribute is + * enabled in the attribute_set and FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_semaphore_Is_priority( + CORE_semaphore_Attributes *the_attribute +); + +#include <rtems/core/coresem.inl> + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ + diff --git a/c/src/exec/score/headers/heap.h b/c/src/exec/score/headers/heap.h index 9eb348a760..bf4a8dde6e 100644 --- a/c/src/exec/score/headers/heap.h +++ b/c/src/exec/score/headers/heap.h @@ -386,7 +386,7 @@ STATIC INLINE unsigned32 _Heap_Build_flag ( unsigned32 in_use_flag ); -#include <rtems/heap.inl> +#include <rtems/core/heap.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/interr.h b/c/src/exec/score/headers/interr.h new file mode 100644 index 0000000000..c1088a9dff --- /dev/null +++ b/c/src/exec/score/headers/interr.h @@ -0,0 +1,93 @@ +/* interr.h + * + * This include file contains constants and prototypes related + * to the Internal Error Handler. + * + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id# + */ + +#ifndef __RTEMS_INTERNAL_ERROR_h +#define __RTEMS_INTERNAL_ERROR_h + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This type lists the possible sources from which an error + * can be reported. + */ + +typedef enum { + INTERNAL_ERROR_CORE, + INTERNAL_ERROR_RTEMS_API +} Internal_errors_Source; + +/* + * A list of errors which are generated internally by the executive core. + */ + +typedef enum { + INTERNAL_ERROR_NO_CONFIGURATION_TABLE, + INTERNAL_ERROR_NO_CPU_TABLE, + INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS, + INTERNAL_ERROR_TOO_LITTLE_WORKSPACE, + INTERNAL_ERROR_WORKSPACE_ALLOCATION, + INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL, + INTERNAL_ERROR_THREAD_EXITTED, + INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION, + INTERNAL_ERROR_INVALID_NODE, + INTERNAL_ERROR_NO_MPCI, + INTERNAL_ERROR_BAD_PACKET, + INTERNAL_ERROR_OUT_OF_PACKETS, + INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS, + INTERNAL_ERROR_OUT_OF_PROXIES, + INTERNAL_ERROR_INVALID_GLOBAL_ID +} Internal_errors_Core_list; + +/* + * This type holds the fatal error information. + */ + +typedef struct { + Internal_errors_Source the_source; + boolean is_internal; + unsigned32 the_error; +} Internal_errors_Information; + +/* + * When a fatal error occurs, the error information is stored here. + */ + +EXTERN Internal_errors_Information Internal_errors_What_happened; + +/* + * _Internal_error_Occurred + * + * DESCRIPTION: + * + * This routine is invoked when the application or the executive itself + * determines that a fatal error has occurred. + */ + +void volatile _Internal_error_Occurred( + Internal_errors_Source the_source, + boolean is_internal, + unsigned32 the_error +); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/c/src/exec/score/headers/isr.h b/c/src/exec/score/headers/isr.h index 77c3f8663e..4bbc3c7aff 100644 --- a/c/src/exec/score/headers/isr.h +++ b/c/src/exec/score/headers/isr.h @@ -16,8 +16,8 @@ * $Id$ */ -#ifndef __RTEMS_ISR_h -#define __RTEMS_ISR_h +#ifndef __ISR_h +#define __ISR_h #ifdef __cplusplus extern "C" { @@ -31,24 +31,23 @@ extern "C" { typedef unsigned32 ISR_Level; /* - * The following type defines the control block used to manage - * the vectors. + * The following type defines the type used to manage the vectors. */ -typedef unsigned32 rtems_vector_number; +typedef unsigned32 ISR_Vector_number; /* * Return type for ISR Handler */ -typedef void rtems_isr; +typedef void ISR_Handler; /* * Pointer to an ISR Handler */ -typedef rtems_isr ( *rtems_isr_entry )( - rtems_vector_number +typedef ISR_Handler ( *ISR_Handler_entry )( + ISR_Vector_number ); /* * The following is TRUE if signals have been sent to the currently @@ -65,11 +64,11 @@ EXTERN boolean _ISR_Signals_to_thread_executing; EXTERN unsigned32 _ISR_Nest_level; /* - * The following declares the RTEMS Vector Table. Application - * interrupt service routines are vectored by RTEMS via this table. + * The following declares the Vector Table. Application + * interrupt service routines are vectored by the ISR Handler via this table. */ -EXTERN rtems_isr_entry _ISR_Vector_table[CPU_INTERRUPT_NUMBER_OF_VECTORS]; +EXTERN ISR_Handler_entry _ISR_Vector_table[CPU_INTERRUPT_NUMBER_OF_VECTORS]; /* * _ISR_Handler_initialization @@ -79,7 +78,7 @@ EXTERN rtems_isr_entry _ISR_Vector_table[CPU_INTERRUPT_NUMBER_OF_VECTORS]; * This routine performs the initialization necessary for this handler. */ -STATIC INLINE void _ISR_Handler_initialization ( void ); +void _ISR_Handler_initialization ( void ); /* * _ISR_Disable @@ -154,6 +153,17 @@ STATIC INLINE boolean _ISR_Is_in_progress( void ); _CPU_ISR_install_vector( _vector, _new_handler, _old_handler ) /* + * _ISR_Get_level + * + * DESCRIPTION: + * + * This routine returns the current interrupt level. + */ + +#define _ISR_Get_level() \ + _CPU_ISR_Get_level() + +/* * _ISR_Set_level * * DESCRIPTION: @@ -176,7 +186,7 @@ STATIC INLINE boolean _ISR_Is_in_progress( void ); */ STATIC INLINE boolean _ISR_Is_vector_number_valid ( - rtems_vector_number vector + ISR_Vector_number vector ); /* @@ -197,7 +207,7 @@ STATIC INLINE boolean _ISR_Is_valid_user_handler ( * * DESCRIPTION: * - * This routine is the RTEMS interrupt dispatcher. ALL interrupts + * This routine is the interrupt dispatcher. ALL interrupts * are vectored to this routine so that minimal context can be saved * and setup performed before the application's high-level language * interrupt service routine is invoked. After the application's @@ -229,7 +239,7 @@ void _ISR_Handler( void ); void _ISR_Dispatch( void ); -#include <rtems/isr.inl> +#include <rtems/core/isr.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/mpci.h b/c/src/exec/score/headers/mpci.h index ca06dd243b..06dc0015d4 100644 --- a/c/src/exec/score/headers/mpci.h +++ b/c/src/exec/score/headers/mpci.h @@ -14,20 +14,20 @@ * $Id$ */ -#ifndef __RTEMS_MPCI_h -#define __RTEMS_MPCI_h +#ifndef __MPCI_h +#define __MPCI_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/mppkt.h> -#include <rtems/states.h> -#include <rtems/status.h> -#include <rtems/thread.h> -#include <rtems/threadq.h> -#include <rtems/tqdata.h> -#include <rtems/watchdog.h> +#include <rtems/core/mppkt.h> +#include <rtems/core/states.h> +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/tqdata.h> +#include <rtems/core/watchdog.h> +#include <rtems/core/coresem.h> /* * The following defines the node number used when a broadcast is desired. @@ -45,6 +45,85 @@ extern "C" { #define MPCI_DEFAULT_TIMEOUT 0xFFFFFFFF /* + * The following records define the Multiprocessor Communications + * Interface (MPCI) Table. This table defines the user-provided + * MPCI which is a required part of a multiprocessor system. + * + * For non-blocking local operations that become remote operations, + * we need a timeout. This is a per-driver timeout: default_timeout + */ + +typedef void MPCI_Entry; + +typedef MPCI_Entry ( *MPCI_initialization_entry )( void ); + +typedef MPCI_Entry ( *MPCI_get_packet_entry )( + MP_packet_Prefix ** + ); + +typedef MPCI_Entry ( *MPCI_return_packet_entry )( + MP_packet_Prefix * + ); + +typedef MPCI_Entry ( *MPCI_send_entry )( + unsigned32, + MP_packet_Prefix * + ); + +typedef MPCI_Entry ( *MPCI_receive_entry )( + MP_packet_Prefix ** + ); + +typedef struct { + unsigned32 default_timeout; /* in ticks */ + unsigned32 maximum_packet_size; + MPCI_initialization_entry initialization; + MPCI_get_packet_entry get_packet; + MPCI_return_packet_entry return_packet; + MPCI_send_entry send_packet; + MPCI_receive_entry receive_packet; +} MPCI_Control; + +/* + * The following defines the type for packet processing routines + * invoked by the MPCI Receive server. + */ + +typedef void (*MPCI_Packet_processor)( MP_packet_Prefix * ); + +/* + * This is the core semaphore which the MPCI Receive Server blocks on. + */ + +EXTERN CORE_semaphore_Control _MPCI_Semaphore; +/* + * The following thread queue is used to maintain a list of tasks + * which currently have outstanding remote requests. + */ + +EXTERN Thread_queue_Control _MPCI_Remote_blocked_threads; + +/* + * The following define the internal pointers to the user's + * configuration information. + */ + +EXTERN MPCI_Control *_MPCI_table; + +/* + * The following points to the MPCI Receive Server. + */ + +EXTERN Thread_Control *_MPCI_Receive_server_tcb; + +/* + * The following table contains the process packet routines provided + * by each object that supports MP operations. + */ + +EXTERN MPCI_Packet_processor _MPCI_Packet_processors[MP_PACKET_CLASSES_LAST+1]; + +/* * _MPCI_Handler_initialization * * DESCRIPTION: @@ -52,7 +131,9 @@ extern "C" { * This routine performs the initialization necessary for this handler. */ -void _MPCI_Handler_initialization ( void ); +void _MPCI_Handler_initialization( + MPCI_Control *users_mpci_table +); /* * _MPCI_Initialization @@ -66,6 +147,21 @@ void _MPCI_Handler_initialization ( void ); void _MPCI_Initialization ( void ); /* + * _MPCI_Register_packet_processor + * + * DESCRIPTION: + * + * This routine registers the MPCI packet processor for the + * designated object class. + */ + +void _MPCI_Register_packet_processor( + MP_packet_Classes the_object, + MPCI_Packet_processor the_packet_processor + +); + +/* * _MPCI_Get_packet * * DESCRIPTION: @@ -74,7 +170,7 @@ void _MPCI_Initialization ( void ); * MPCI get packet callout. */ -rtems_packet_prefix *_MPCI_Get_packet ( void ); +MP_packet_Prefix *_MPCI_Get_packet ( void ); /* * _MPCI_Return_packet @@ -86,7 +182,7 @@ rtems_packet_prefix *_MPCI_Get_packet ( void ); */ void _MPCI_Return_packet ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); /* @@ -100,7 +196,7 @@ void _MPCI_Return_packet ( void _MPCI_Send_process_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); /* @@ -112,9 +208,9 @@ void _MPCI_Send_process_packet ( * MPCI send callout. */ -rtems_status_code _MPCI_Send_request_packet ( +unsigned32 _MPCI_Send_request_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet, + MP_packet_Prefix *the_packet, States_Control extra_state ); @@ -129,7 +225,7 @@ rtems_status_code _MPCI_Send_request_packet ( void _MPCI_Send_response_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); /* @@ -141,7 +237,7 @@ void _MPCI_Send_response_packet ( * MPCI receive callout. */ -rtems_packet_prefix *_MPCI_Receive_packet ( void ); +MP_packet_Prefix *_MPCI_Receive_packet ( void ); /* * _MPCI_Process_response @@ -153,15 +249,27 @@ rtems_packet_prefix *_MPCI_Receive_packet ( void ); */ Thread_Control *_MPCI_Process_response ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); -/* - * The following thread queue is used to maintain a list of tasks - * which currently have outstanding remote requests. +/*PAGE + * + * _MPCI_Receive_server + * */ + +void _MPCI_Receive_server( void ); -EXTERN Thread_queue_Control _MPCI_Remote_blocked_threads; +/*PAGE + * + * _MPCI_Announce + * + * DESCRIPTION: + * + * XXX + */ + +void _MPCI_Announce ( void ); #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/mppkt.h b/c/src/exec/score/headers/mppkt.h index d63d587fca..32cbc7e0e9 100644 --- a/c/src/exec/score/headers/mppkt.h +++ b/c/src/exec/score/headers/mppkt.h @@ -1,8 +1,10 @@ /* mppkt.h * * This package is the specification for the Packet Handler. - * This handler defines the basic RTEMS packet and provides + * This handler defines the basic packet and provides * mechanisms to utilize packets based on this prefix. + * Packets are the fundamental basis for messages passed between + * nodes in an MP system. * * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. @@ -16,20 +18,19 @@ * $Id$ */ -#ifndef __RTEMS_MP_PACKET_h -#define __RTEMS_MP_PACKET_h +#ifndef __MP_PACKET_h +#define __MP_PACKET_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/object.h> -#include <rtems/priority.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/priority.h> +#include <rtems/core/watchdog.h> /* - * The following enumerated type defines the packet classes - * supported by RTEMS. + * The following enumerated type defines the packet classes. * * NOTE: In general, each class corresponds to a manager * which supports global operations. Each manager @@ -37,55 +38,55 @@ extern "C" { */ typedef enum { - RTEMS_MP_PACKET_INTERNAL_THREADS = 0, - RTEMS_MP_PACKET_TASKS = 1, - RTEMS_MP_PACKET_MESSAGE_QUEUE = 2, - RTEMS_MP_PACKET_SEMAPHORE = 3, - RTEMS_MP_PACKET_PARTITION = 4, - RTEMS_MP_PACKET_REGION = 5, - RTEMS_MP_PACKET_EVENT = 6, - RTEMS_MP_PACKET_SIGNAL = 7 -} rtems_mp_packet_classes; - -#define MP_PACKET_CLASSES_FIRST RTEMS_MP_PACKET_INTERNAL_THREADS -#define MP_PACKET_CLASSES_LAST RTEMS_MP_PACKET_SIGNAL + MP_PACKET_INTERNAL_THREADS = 0, + MP_PACKET_TASKS = 1, + MP_PACKET_MESSAGE_QUEUE = 2, + MP_PACKET_SEMAPHORE = 3, + MP_PACKET_PARTITION = 4, + MP_PACKET_REGION = 5, + MP_PACKET_EVENT = 6, + MP_PACKET_SIGNAL = 7 +} MP_packet_Classes; + +#define MP_PACKET_CLASSES_FIRST MP_PACKET_INTERNAL_THREADS +#define MP_PACKET_CLASSES_LAST MP_PACKET_SIGNAL /* * The following record contains the prefix for every packet - * passed between RTEMS nodes. + * passed between nodes in an MP system. * * NOTE: This structure is padded to insure that anything * following it is on a 16 byte boundary. This is * the most stringent structure alignment rule - * the RTEMS project has encountered yet (i960CA). + * encountered yet (i960CA). */ typedef struct { - rtems_mp_packet_classes the_class; + MP_packet_Classes the_class; Objects_Id id; Objects_Id source_tid; Priority_Control source_priority; - rtems_status_code return_code; + unsigned32 return_code; unsigned32 length; unsigned32 to_convert; - rtems_interval timeout; -} rtems_packet_prefix; + Watchdog_Interval timeout; +} MP_packet_Prefix; /* * An MPCI must support packets of at least this size. */ -#define RTEMS_MINIMUM_PACKET_SIZE 64 +#define MP_PACKET_MINIMUM_PACKET_SIZE 64 /* * The following constant defines the number of unsigned32's * in a packet which must be converted to native format in a * heterogeneous system. In packets longer than - * RTEMS_MINIMUN_HETERO_CONVERSION unsigned32's, some of the "extra" data + * MP_PACKET_MINIMUN_HETERO_CONVERSION unsigned32's, some of the "extra" data * may a user message buffer which is not automatically endian swapped. */ -#define RTEMS_MINIMUN_HETERO_CONVERSION ( sizeof( rtems_packet_prefix ) / 4 ) +#define MP_PACKET_MINIMUN_HETERO_CONVERSION ( sizeof( MP_packet_Prefix ) / 4 ) /* * _Mp_packet_Is_valid_packet_class @@ -97,7 +98,7 @@ typedef struct { */ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( - rtems_mp_packet_classes the_packet_class + MP_packet_Classes the_packet_class ); /* @@ -110,10 +111,10 @@ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( */ STATIC INLINE boolean _Mp_packet_Is_null ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); -#include <rtems/mppkt.inl> +#include <rtems/core/mppkt.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/object.h b/c/src/exec/score/headers/object.h index b1d422d3d4..3da299e95f 100644 --- a/c/src/exec/score/headers/object.h +++ b/c/src/exec/score/headers/object.h @@ -1,8 +1,9 @@ /* object.h * * This include file contains all the constants and structures associated - * with the RTEMS Object Handler. This Handler provides mechanisms which - * can be used to initialize and manipulate all RTEMS objects. + * with the Object Handler. This Handler provides mechanisms which + * can be used to initialize and manipulate all objects which have + * ids. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,14 +16,14 @@ * $Id$ */ -#ifndef __RTEMS_OBJECTS_h -#define __RTEMS_OBJECTS_h +#ifndef __OBJECTS_h +#define __OBJECTS_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/chain.h> +#include <rtems/core/chain.h> /* * The following type defines the control block used to manage @@ -142,6 +143,7 @@ typedef struct { */ EXTERN unsigned32 _Objects_Local_node; +EXTERN unsigned32 _Objects_Maximum_nodes; /* * The following is the list of information blocks for each object @@ -164,23 +166,23 @@ EXTERN Objects_Information * The following define the constants which may be used in name searches. */ -#define RTEMS_SEARCH_ALL_NODES 0 -#define RTEMS_SEARCH_OTHER_NODES 0x7FFFFFFE -#define RTEMS_SEARCH_LOCAL_NODE 0x7FFFFFFF -#define RTEMS_WHO_AM_I 0 +#define OBJECTS_SEARCH_ALL_NODES 0 +#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE +#define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF +#define OBJECTS_WHO_AM_I 0 /* * Parameters and return id's for _Objects_Get_next */ -#define RTEMS_OBJECT_ID_INITIAL_INDEX (0) -#define RTEMS_OBJECT_ID_FINAL_INDEX (0xffff) +#define OBJECTS_ID_INITIAL_INDEX (0) +#define OBJECTS_ID_FINAL_INDEX (0xffff) -#define RTEMS_OBJECT_ID_INITIAL(node) (_Objects_Build_id( \ - OBJECTS_NO_CLASS, \ - node, \ - RTEMS_OBJECT_ID_INITIAL_INDEX)) -#define RTEMS_OBJECT_ID_FINAL ((Objects_Id)~0) +#define OBJECTS_ID_INITIAL(node) (_Objects_Build_id( \ + OBJECTS_NO_CLASS, \ + node, \ + OBJECTS_ID_INITIAL_INDEX)) +#define OBJECTS_ID_FINAL ((Objects_Id)~0) /* * _Objects_Handler_initialization @@ -193,6 +195,7 @@ EXTERN Objects_Information void _Objects_Handler_initialization( unsigned32 node, + unsigned32 maximum_nodes, unsigned32 maximum_global_objects ); @@ -303,7 +306,16 @@ boolean _Objects_Compare_name_raw( * */ -rtems_status_code _Objects_Name_to_id( +typedef enum { + OBJECTS_SUCCESSFUL, + OBJECTS_INVALID_NAME, + OBJECTS_INVALID_NODE +} Objects_Name_to_id_errors; + +#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_SUCCESSFUL +#define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE + +Objects_Name_to_id_errors _Objects_Name_to_id( Objects_Information *information, Objects_Name name, unsigned32 node, @@ -378,7 +390,7 @@ STATIC INLINE Objects_Id _Objects_Build_id( ); /* - * rtems_get_class + * _Objects_Get_class * * DESCRIPTION: * @@ -386,12 +398,12 @@ STATIC INLINE Objects_Id _Objects_Build_id( * */ -STATIC INLINE Objects_Classes rtems_get_class( +STATIC INLINE Objects_Classes _Objects_Get_class( Objects_Id id ); /* - * rtems_get_node + * _Objects_Get_node * * DESCRIPTION: * @@ -399,12 +411,12 @@ STATIC INLINE Objects_Classes rtems_get_class( * */ -STATIC INLINE unsigned32 rtems_get_node( +STATIC INLINE unsigned32 _Objects_Get_node( Objects_Id id ); /* - * rtems_get_index + * _Objects_Get_index * * DESCRIPTION: * @@ -412,7 +424,7 @@ STATIC INLINE unsigned32 rtems_get_node( * */ -STATIC INLINE unsigned32 rtems_get_index( +STATIC INLINE unsigned32 _Objects_Get_index( Objects_Id id ); @@ -532,7 +544,7 @@ STATIC INLINE void _Objects_Close( Objects_Control *the_object ); -#include <rtems/object.inl> +#include <rtems/core/object.inl> #include <rtems/objectmp.h> #ifdef __cplusplus diff --git a/c/src/exec/score/headers/objectmp.h b/c/src/exec/score/headers/objectmp.h index b15d5cbb43..cef5c6879d 100644 --- a/c/src/exec/score/headers/objectmp.h +++ b/c/src/exec/score/headers/objectmp.h @@ -42,6 +42,8 @@ typedef struct { */ void _Objects_MP_Handler_initialization ( + unsigned32 node, + unsigned32 maximum_nodes, unsigned32 maximum_global_objects ); @@ -140,7 +142,7 @@ void _Objects_MP_Close ( * object with that name if one is found. */ -rtems_status_code _Objects_MP_Global_name_search ( +Objects_Name_to_id_errors _Objects_MP_Global_name_search ( Objects_Information *information, Objects_Name the_name, unsigned32 nodes_to_search, @@ -171,6 +173,7 @@ void _Objects_MP_Is_remote ( * inactive global object control blocks. */ +EXTERN unsigned32 _Objects_MP_Maximum_global_objects; EXTERN Chain_Control _Objects_MP_Inactive_global_objects; #include <rtems/objectmp.inl> diff --git a/c/src/exec/score/headers/priority.h b/c/src/exec/score/headers/priority.h index 44397e7a8a..8f681c0ce1 100644 --- a/c/src/exec/score/headers/priority.h +++ b/c/src/exec/score/headers/priority.h @@ -2,7 +2,7 @@ * * This include file contains all thread priority manipulation routines. * This Handler provides mechanisms which can be used to - * initialize and manipulate RTEMS priorities. + * initialize and manipulate thread priorities. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,8 +15,8 @@ * $Id$ */ -#ifndef __RTEMS_PRIORITY_h -#define __RTEMS_PRIORITY_h +#ifndef __PRIORITY_h +#define __PRIORITY_h #ifdef __cplusplus extern "C" { @@ -31,8 +31,8 @@ extern "C" { typedef unsigned32 Priority_Control; -#define RTEMS_MINIMUM_PRIORITY 1 /* highest thread priority */ -#define RTEMS_MAXIMUM_PRIORITY 255 /* lowest thread priority */ +#define PRIORITY_MINIMUM 0 /* highest thread priority */ +#define PRIORITY_MAXIMUM 255 /* lowest thread priority */ /* * The following record defines the information associated with @@ -62,12 +62,6 @@ EXTERN volatile Priority_Bit_map_control _Priority_Major_bit_map; EXTERN Priority_Bit_map_control _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; /* - * The following constants are useful when manipulating priority. - */ - -#define RTEMS_CURRENT_PRIORITY 0 /* obtain current priority */ - -/* * The definition of the Priority_Bit_map_control type is CPU dependent. * */ @@ -185,7 +179,7 @@ STATIC INLINE boolean _Priority_Is_group_empty ( Priority_Control the_priority ); -#include <rtems/priority.inl> +#include <rtems/core/priority.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/stack.h b/c/src/exec/score/headers/stack.h index a0fce1ef04..2a41bcf89f 100644 --- a/c/src/exec/score/headers/stack.h +++ b/c/src/exec/score/headers/stack.h @@ -15,8 +15,8 @@ * $Id$ */ -#ifndef __RTEMS_STACK_h -#define __RTEMS_STACK_h +#ifndef __STACK_h +#define __STACK_h #ifdef __cplusplus extern "C" { @@ -27,7 +27,7 @@ extern "C" { * thread must exceed. */ -#define RTEMS_MINIMUM_STACK_SIZE CPU_STACK_MINIMUM_SIZE +#define STACK_MINIMUM_SIZE CPU_STACK_MINIMUM_SIZE /* * The following defines the control block used to manage each stack. @@ -85,7 +85,7 @@ STATIC INLINE unsigned32 _Stack_Adjust_size ( unsigned32 size ); -#include <rtems/stack.inl> +#include <rtems/core/stack.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/states.h b/c/src/exec/score/headers/states.h index 56f67ecc49..3f7c4a7e99 100644 --- a/c/src/exec/score/headers/states.h +++ b/c/src/exec/score/headers/states.h @@ -1,6 +1,6 @@ /* states.h * - * This include file contains all RTEMS state information. + * This include file contains thread execution state information. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -43,13 +43,15 @@ typedef unsigned32 States_Control; #define STATES_WAITING_FOR_MESSAGE 0x0040 /* wait for message */ #define STATES_WAITING_FOR_EVENT 0x0080 /* wait for event */ #define STATES_WAITING_FOR_SEMAPHORE 0x0100 /* wait for semaphore */ -#define STATES_WAITING_FOR_TIME 0x0200 /* wait for specific TOD */ -#define STATES_WAITING_FOR_RPC_REPLY 0x0400 /* wait for rpc reply */ -#define STATES_WAITING_FOR_PERIOD 0x0800 /* rate monotonic delay */ +#define STATES_WAITING_FOR_MUTEX 0x0200 /* wait for mutex */ +#define STATES_WAITING_FOR_TIME 0x0400 /* wait for specific TOD */ +#define STATES_WAITING_FOR_RPC_REPLY 0x0800 /* wait for rpc reply */ +#define STATES_WAITING_FOR_PERIOD 0x1000 /* rate monotonic delay */ #define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_BUFFER | \ STATES_WAITING_FOR_SEGMENT | \ STATES_WAITING_FOR_MESSAGE | \ + STATES_WAITING_FOR_MUTEX | \ STATES_WAITING_FOR_SEMAPHORE ) #define STATES_WAITING_ON_THREAD_QUEUE \ @@ -221,6 +223,19 @@ STATIC INLINE boolean _States_Is_waiting_for_event ( ); /* + * _States_Is_waiting_for_mutex + * + * DESCRIPTION: + * + * This function returns TRUE if the WAITING_FOR_MUTEX state + * is set in the_states, and FALSE otherwise. + */ + +STATIC INLINE boolean _States_Is_waiting_for_mutex ( + States_Control the_states +); + +/* * _States_Is_waiting_for_semaphore * * DESCRIPTION: @@ -327,7 +342,7 @@ STATIC INLINE boolean _States_Are_set ( States_Control mask ); -#include <rtems/states.inl> +#include <rtems/core/states.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/sysstate.h b/c/src/exec/score/headers/sysstate.h index 511a26cefc..b0ace61f98 100644 --- a/c/src/exec/score/headers/sysstate.h +++ b/c/src/exec/score/headers/sysstate.h @@ -40,12 +40,31 @@ typedef enum { #define SYSTEM_STATE_CODES_LAST SYSTEM_STATE_FAILED /* + * The following variable indicates whether or not this is + * an multiprocessing system. + */ + +EXTERN boolean _System_state_Is_multiprocessing; + +/* * The following variable contains the current system state. */ EXTERN System_state_Codes _System_state_Current; /* + * _System_state_Handler_initialization + * + * DESCRIPTION: + * + * This routine initializes the system state handler. + */ + +STATIC INLINE void _System_state_Handler_initialization ( + boolean is_multiprocessing +); + +/* * _System_state_Set * * DESCRIPTION: diff --git a/c/src/exec/score/headers/system.h b/c/src/exec/score/headers/system.h index 5f627c1a7c..037fe93e66 100644 --- a/c/src/exec/score/headers/system.h +++ b/c/src/exec/score/headers/system.h @@ -76,9 +76,7 @@ extern "C" { typedef void * proc_ptr; -#include <rtems/cpu.h> /* processor specific information */ -#include <rtems/status.h> /* RTEMS status codes */ -#include <rtems/directives.h> +#include <rtems/core/cpu.h> /* processor specific information */ /* * Define NULL @@ -116,12 +114,6 @@ extern const char _RTEMS_version[]; /* RTEMS version string */ extern const char _Copyright_Notice[]; /* RTEMS copyright string */ /* - * The jump table of entry points into RTEMS directives. - */ - -extern const void * _Entry_points[ RTEMS_NUMBER_OF_ENTRY_POINTS ]; - -/* * The following defines the CPU dependent information table. */ diff --git a/c/src/exec/score/headers/thread.h b/c/src/exec/score/headers/thread.h index 37a5898d01..823a4e6760 100644 --- a/c/src/exec/score/headers/thread.h +++ b/c/src/exec/score/headers/thread.h @@ -14,77 +14,44 @@ * $Id$ */ -#ifndef __RTEMS_THREAD_h -#define __RTEMS_THREAD_h +#ifndef __THREAD_h +#define __THREAD_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/asr.h> -#include <rtems/attr.h> -#include <rtems/context.h> -#include <rtems/cpu.h> -#include <rtems/eventset.h> -#include <rtems/modes.h> -#include <rtems/mppkt.h> -#include <rtems/object.h> -#include <rtems/options.h> -#include <rtems/priority.h> -#include <rtems/stack.h> -#include <rtems/states.h> -#include <rtems/tod.h> -#include <rtems/tqdata.h> -#include <rtems/watchdog.h> - -/* - * Notepads constants (indices into notepad array) - */ - -#define RTEMS_NOTEPAD_FIRST 0 /* lowest numbered notepad */ -#define RTEMS_NOTEPAD_0 0 /* notepad location 0 */ -#define RTEMS_NOTEPAD_1 1 /* notepad location 1 */ -#define RTEMS_NOTEPAD_2 2 /* notepad location 2 */ -#define RTEMS_NOTEPAD_3 3 /* notepad location 3 */ -#define RTEMS_NOTEPAD_4 4 /* notepad location 4 */ -#define RTEMS_NOTEPAD_5 5 /* notepad location 5 */ -#define RTEMS_NOTEPAD_6 6 /* notepad location 6 */ -#define RTEMS_NOTEPAD_7 7 /* notepad location 7 */ -#define RTEMS_NOTEPAD_8 8 /* notepad location 8 */ -#define RTEMS_NOTEPAD_9 9 /* notepad location 9 */ -#define RTEMS_NOTEPAD_10 10 /* notepad location 10 */ -#define RTEMS_NOTEPAD_11 11 /* notepad location 11 */ -#define RTEMS_NOTEPAD_12 12 /* notepad location 12 */ -#define RTEMS_NOTEPAD_13 13 /* notepad location 13 */ -#define RTEMS_NOTEPAD_14 14 /* notepad location 14 */ -#define RTEMS_NOTEPAD_15 15 /* notepad location 15 */ -#define RTEMS_NOTEPAD_LAST RTEMS_NOTEPAD_15 /* highest numbered notepad */ - -#define RTEMS_NUMBER_NOTEPADS (RTEMS_NOTEPAD_LAST+1) - -/* - * The following defines the "return type" of an RTEMS thread. - * - * NOTE: Keep both types for internal threads. - */ - -typedef void rtems_task; -typedef void Thread; +#include <rtems/core/context.h> +#include <rtems/core/cpu.h> +#include <rtems/core/mppkt.h> +#include <rtems/core/object.h> +#include <rtems/core/priority.h> +#include <rtems/core/stack.h> +#include <rtems/core/states.h> +#include <rtems/core/tod.h> +#include <rtems/core/tqdata.h> +#include <rtems/core/watchdog.h> /* - * The following defines the argument to an RTEMS thread. + * The following defines the "return type" of a thread. */ -typedef unsigned32 rtems_task_argument; -typedef unsigned32 Thread_Argument; +typedef void Thread; /* - * The following defines the type for the entry point of an RTEMS thread. + * The following defines the ways in which the entry point for a + * thread can be invoked. Basically, it can be passed any + * combination/permutation of a pointer and an unsigned32 value. + * + * NOTE: For now, we are ignoring the return type. */ -typedef rtems_task ( *rtems_task_entry )( - rtems_task_argument - ); +typedef enum { + THREAD_START_NUMERIC, + THREAD_START_POINTER, + THREAD_START_BOTH_POINTER_FIRST, + THREAD_START_BOTH_NUMERIC_FIRST +} Thread_Start_types; typedef Thread ( *Thread_Entry )( ); @@ -93,19 +60,15 @@ typedef Thread ( *Thread_Entry )( ); * the starting state of a thread. */ -typedef enum { - THREAD_START_NUMERIC, - THREAD_START_POINTER, - THREAD_START_BOTH_POINTER_FIRST, - THREAD_START_BOTH_NUMERIC_FIRST -} Thread_Start_types; - typedef struct { Thread_Entry entry_point; /* starting thread address */ Thread_Start_types prototype; /* how task is invoked */ void *pointer_argument; /* pointer argument */ unsigned32 numeric_argument; /* numeric argument */ - Modes_Control initial_modes; /* initial mode */ + /* initial execution modes */ + boolean is_preemptible; + boolean is_timeslice; + unsigned32 isr_level; Priority_Control initial_priority; /* initial priority */ Stack_Control Initial_stack; /* stack information */ void *fp_context; /* initial FP context area address */ @@ -117,16 +80,21 @@ typedef struct { * a thread which it is waiting for a resource. */ +#define THREAD_STATUS_PROXY_BLOCKING 0x1111111 + typedef struct { Objects_Id id; /* waiting on this object */ - rtems_option option_set; /* wait mode */ - union { - unsigned32 segment_size; /* size of segment requested */ - rtems_event_set event_condition; - unsigned32 *message_size_p; /* ptr for return size of message */ - } Extra; - void *return_argument; /* address of user return param */ - rtems_status_code return_code; /* status for thread awakened */ + unsigned32 count; /* "generic" fields to be used */ + void *return_argument; /* when blocking */ + void *return_argument_1; + unsigned32 option; + + /* + * NOTE: The following assumes that all API return codes can be + * treated as an unsigned32. + */ + unsigned32 return_code; /* status for thread awakened */ + Chain_Control Block2n; /* 2 - n priority blocked chain */ Thread_queue_Control *queue; /* pointer to thread queue */ } Thread_Wait_information; @@ -147,7 +115,7 @@ typedef struct { unsigned32 resource_count; Thread_Wait_information Wait; Watchdog_Control Timer; - rtems_packet_prefix *receive_packet; + MP_packet_Prefix *receive_packet; /****************** end of common block ********************/ Chain_Node Active; } Thread_Proxy_control; @@ -161,15 +129,12 @@ typedef struct { * memory images for the shared part. */ -/* XXX structure in wrong file .. API .. not core */ +typedef enum { + THREAD_API_RTEMS +} Thread_APIs; -typedef struct { - boolean is_global; - unsigned32 Notepads[ RTEMS_NUMBER_NOTEPADS ]; - rtems_event_set pending_events; - rtems_event_set events_out; - ASR_Information Signal; -} RTEMS_API_Control; +#define THREAD_API_FIRST THREAD_API_RTEMS +#define THREAD_API_LAST THREAD_API_RTEMS typedef struct { Objects_Control Object; @@ -179,24 +144,30 @@ typedef struct { unsigned32 resource_count; Thread_Wait_information Wait; Watchdog_Control Timer; - rtems_packet_prefix *receive_packet; + MP_packet_Prefix *receive_packet; /****************** end of common block ********************/ + boolean is_global; Chain_Control *ready; Priority_Information Priority_map; Thread_Start_information Start; - Modes_Control current_modes; + boolean is_preemptible; + boolean is_timeslice; Context_Control Registers; void *fp_context; - RTEMS_API_Control *RTEMS_API; - void *extension; + void *API_Extensions[ THREAD_API_LAST + 1 ]; + void **extensions; } Thread_Control; /* - * External API name for Thread_Control + * The following context area contains the context of the "thread" + * which invoked the start multitasking routine. This context is + * restored as the last action of the stop multitasking routine. Thus + * control of the processor can be returned to the environment + * which initiated the system. */ - -typedef Thread_Control rtems_tcb; - + +EXTERN Context_Control _Thread_BSP_context; + /* * The following declares the dispatch critical section nesting * counter which is used to prevent context switches at inopportune @@ -206,6 +177,14 @@ typedef Thread_Control rtems_tcb; EXTERN unsigned32 _Thread_Dispatch_disable_level; /* + * The following holds how many user extensions are in the system. This + * is used to determine how many user extension data areas to allocate + * per thread. + */ + +EXTERN unsigned32 _Thread_Maximum_extensions; + +/* * The following data items are used to manage timeslicing. */ @@ -228,7 +207,7 @@ EXTERN Thread_Control *_Thread_Executing; /* * The following points to the highest priority ready thread - * in the system. Unless the current thread is RTEMS_NO_PREEMPT, + * in the system. Unless the current thread is not preemptibl, * then this thread will be context switched to when the next * dispatch occurs. */ @@ -243,16 +222,6 @@ EXTERN Thread_Control *_Thread_Heir; EXTERN Thread_Control *_Thread_Allocated_fp; /* - * The following context area contains the context of the "thread" - * which invoked rtems_initialize_executive. This context is restored - * as the last action of the rtems_shutdown_executive directive. Thus - * control of the processor can be returned to the environment - * which initiated RTEMS. - */ - -EXTERN Context_Control _Thread_BSP_context; - -/* * _Thread_Handler_initialization * * DESCRIPTION: @@ -261,8 +230,9 @@ EXTERN Context_Control _Thread_BSP_context; */ void _Thread_Handler_initialization ( - unsigned32 ticks_per_timeslice, - unsigned32 maximum_proxies + unsigned32 ticks_per_timeslice, + unsigned32 maximum_extensions, + unsigned32 maximum_proxies ); /* @@ -272,7 +242,7 @@ void _Thread_Handler_initialization ( * * This routine initiates multitasking. It is invoked only as * part of initialization and its invocation is the last act of - * the rtems_initialize_executive directive. + * the non-multitasking part of the system initialization. */ void _Thread_Start_multitasking ( @@ -286,8 +256,8 @@ void _Thread_Start_multitasking ( * DESCRIPTION: * * This routine halts multitasking and returns control to - * the "thread" which initially invoked the rtems_initialize_executive - * directive. + * the "thread" (i.e. the BSP) which initially invoked the + * routine which initialized the system. */ STATIC INLINE void _Thread_Stop_multitasking( void ); @@ -333,7 +303,9 @@ boolean _Thread_Initialize( unsigned32 stack_size, /* insure it is >= min */ boolean is_fp, /* TRUE if thread uses FP */ Priority_Control priority, - Modes_Control mode, + boolean is_preemptible, + boolean is_timeslice, + unsigned32 isr_level, Objects_Name name ); @@ -452,7 +424,7 @@ void _Thread_Set_transient( * at the priority of the currently executing thread, then the * executing thread's timeslice is reset. Otherwise, the * currently executing thread is placed at the rear of the - * RTEMS_FIFO for this priority and a new heir is selected. + * FIFO for this priority and a new heir is selected. */ void _Thread_Reset_timeslice( void ); @@ -551,8 +523,7 @@ void _Thread_Handler( void ); * DESCRIPTION: * * This routine is invoked when a thread must be unblocked at the - * end of a delay such as the rtems_task_wake_after and rtems_task_wake_when - * directives. + * end of a time based delay (i.e. wake after or wake when). */ void _Thread_Delay_ended( @@ -590,23 +561,14 @@ void _Thread_Set_priority( ); /* - * _Thread_Change_mode + * _Thread_Evaluate_mode * * DESCRIPTION: * - * This routine changes the current values of the modes - * indicated by mask of the calling thread are changed to that - * indicated in mode_set. The former mode of the thread is - * returned in mode_set. If the changes in the current mode - * indicate that a thread dispatch operation may be necessary, - * then need_dispatch is TRUE, otherwise it is FALSE. + * This routine XXX */ -boolean _Thread_Change_mode( - Modes_Control new_mode_set, - Modes_Control mask, - Modes_Control *old_mode_set -); +boolean _Thread_Evaluate_mode( void ); /* * _Thread_Resume @@ -782,8 +744,21 @@ STATIC INLINE Thread_Control *_Thread_Get ( Objects_Locations *location ); -#include <rtems/thread.inl> -#include <rtems/threadmp.h> +/* + * _Thread_Is_proxy_blocking + * + * DESCRIPTION: + * + * This function returns TRUE if the status code is equal to the + * status which indicates that a proxy is blocking, and FALSE otherwise. + */ + +STATIC INLINE boolean _Thread_Is_proxy_blocking ( + unsigned32 code +); + +#include <rtems/core/thread.inl> +#include <rtems/core/threadmp.h> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/threadmp.h b/c/src/exec/score/headers/threadmp.h index db94a65d78..89b8e3d597 100644 --- a/c/src/exec/score/headers/threadmp.h +++ b/c/src/exec/score/headers/threadmp.h @@ -104,7 +104,7 @@ EXTERN Thread_Control *_Thread_MP_Receive; EXTERN Chain_Control _Thread_MP_Active_proxies; EXTERN Chain_Control _Thread_MP_Inactive_proxies; -#include <rtems/threadmp.inl> +#include <rtems/core/threadmp.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/threadq.h b/c/src/exec/score/headers/threadq.h index 27a36ab63e..a9fb29bb57 100644 --- a/c/src/exec/score/headers/threadq.h +++ b/c/src/exec/score/headers/threadq.h @@ -14,18 +14,18 @@ * $Id$ */ -#ifndef __RTEMS_THREAD_QUEUE_h -#define __RTEMS_THREAD_QUEUE_h +#ifndef __THREAD_QUEUE_h +#define __THREAD_QUEUE_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/tqdata.h> +#include <rtems/core/tqdata.h> -#include <rtems/object.h> -#include <rtems/thread.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/thread.h> +#include <rtems/core/watchdog.h> /* * The following type defines the callout used when a remote task @@ -75,7 +75,7 @@ Thread_Control *_Thread_queue_Dequeue( void _Thread_queue_Enqueue( Thread_queue_Control *the_thread_queue, - rtems_interval timeout + Watchdog_Interval timeout ); /* @@ -131,7 +131,8 @@ Thread_Control *_Thread_queue_First( void _Thread_queue_Flush( Thread_queue_Control *the_thread_queue, - Thread_queue_Flush_callout remote_extract_callout + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status ); /* @@ -149,7 +150,8 @@ void _Thread_queue_Initialize( Objects_Classes the_class, Thread_queue_Disciplines the_discipline, States_Control state, - Thread_queue_Extract_callout proxy_extract_callout + Thread_queue_Extract_callout proxy_extract_callout, + unsigned32 timeout_status ); /* @@ -179,7 +181,7 @@ Thread_Control *_Thread_queue_Dequeue_priority( void _Thread_queue_Enqueue_priority( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, - rtems_interval timeout + Watchdog_Interval timeout ); /* @@ -231,13 +233,13 @@ Thread_Control *_Thread_queue_Dequeue_fifo( * * This routine enqueues the currently executing thread on * the_thread_queue with an optional timeout using the - * RTEMS_FIFO discipline. + * FIFO discipline. */ void _Thread_queue_Enqueue_fifo( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, - rtems_interval timeout + Watchdog_Interval timeout ); /* diff --git a/c/src/exec/score/headers/tod.h b/c/src/exec/score/headers/tod.h index ae7e2b9747..6c2882a3c5 100644 --- a/c/src/exec/score/headers/tod.h +++ b/c/src/exec/score/headers/tod.h @@ -14,15 +14,15 @@ * $Id$ */ -#ifndef __RTEMS_TIME_OF_DAY_h -#define __RTEMS_TIME_OF_DAY_h +#ifndef __TIME_OF_DAY_h +#define __TIME_OF_DAY_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/object.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/watchdog.h> /* * The following constants are related to the time of day. @@ -42,7 +42,7 @@ extern "C" { /* * The following constant define the earliest year to which an - * RTEMS time of day can be initialized. This is considered the + * time of day can be initialized. This is considered the * epoch. */ @@ -61,27 +61,27 @@ typedef struct { /* RTEID style time/date */ unsigned32 minute; /* minute, 0 -> 59 */ unsigned32 second; /* second, 0 -> 59 */ unsigned32 ticks; /* elapsed ticks between secs */ -} rtems_time_of_day; +} TOD_Control; /* * The following contains the current time of day. */ -EXTERN rtems_time_of_day _TOD_Current; +EXTERN TOD_Control _TOD_Current; /* * The following contains the number of seconds from 00:00:00 * January 1, TOD_BASE_YEAR until the current time of day. */ -EXTERN rtems_interval _TOD_Seconds_since_epoch; +EXTERN Watchdog_Interval _TOD_Seconds_since_epoch; /* * The following contains the number of ticks since the * system was booted. */ -EXTERN rtems_interval _TOD_Ticks_since_boot; +EXTERN Watchdog_Interval _TOD_Ticks_since_boot; /* * The following contains the number of microseconds per tick. @@ -173,8 +173,8 @@ void _TOD_Handler_initialization( */ void _TOD_Set( - rtems_time_of_day *the_tod, - rtems_interval seconds_since_epoch + TOD_Control *the_tod, + Watchdog_Interval seconds_since_epoch ); /* @@ -182,12 +182,12 @@ void _TOD_Set( * * DESCRIPTION: * - * This function returns STATUS.RTEMS_SUCCESSFUL if THE_TOD contains + * This function returns TRUE if THE_TOD contains * a valid time of day, and FALSE otherwise. */ -rtems_status_code _TOD_Validate( - rtems_time_of_day *the_tod +boolean _TOD_Validate( + TOD_Control *the_tod ); /* @@ -198,8 +198,8 @@ rtems_status_code _TOD_Validate( * This function returns the number seconds between the epoch and THE_TOD. */ -rtems_interval _TOD_To_seconds( - rtems_time_of_day *the_tod +Watchdog_Interval _TOD_To_seconds( + TOD_Control *the_tod ); /* @@ -243,7 +243,7 @@ STATIC INLINE void _TOD_Deactivate( void ); */ STATIC INLINE void _TOD_Activate( - rtems_interval ticks + Watchdog_Interval ticks ); /* @@ -262,7 +262,7 @@ void _TOD_Tickle( ); /* - * RTEMS_MILLISECONDS_TO_MICROSECONDS + * TOD_MILLISECONDS_TO_MICROSECONDS * * DESCRIPTION: * @@ -273,10 +273,10 @@ void _TOD_Tickle( * This must be a macro so it can be used in "static" tables. */ -#define RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000) +#define TOD_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000) /* - * RTEMS_MILLISECONDS_TO_TICKS + * TOD_MILLISECONDS_TO_TICKS * * DESCRIPTION: * @@ -287,10 +287,10 @@ void _TOD_Tickle( * This must be a macro so it can be used in "static" tables. */ -#define RTEMS_MILLISECONDS_TO_TICKS(_ms) \ - (RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick) +#define TOD_MILLISECONDS_TO_TICKS(_ms) \ + (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick) -#include <rtems/tod.inl> +#include <rtems/core/tod.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/tqdata.h b/c/src/exec/score/headers/tqdata.h index f962f409d2..128c4183a3 100644 --- a/c/src/exec/score/headers/tqdata.h +++ b/c/src/exec/score/headers/tqdata.h @@ -14,16 +14,16 @@ * $Id$ */ -#ifndef __RTEMS_THREAD_QUEUE_DATA_h -#define __RTEMS_THREAD_QUEUE_DATA_h +#ifndef __THREAD_QUEUE_DATA_h +#define __THREAD_QUEUE_DATA_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/chain.h> -#include <rtems/priority.h> -#include <rtems/states.h> +#include <rtems/core/chain.h> +#include <rtems/core/priority.h> +#include <rtems/core/states.h> /* * The following enumerated type details all of the disciplines @@ -31,8 +31,8 @@ extern "C" { */ typedef enum { - THREAD_QUEUE_DISCIPLINE_FIFO, /* RTEMS_FIFO queue discipline */ - THREAD_QUEUE_DISCIPLINE_PRIORITY /* RTEMS_PRIORITY queue discipline */ + THREAD_QUEUE_DISCIPLINE_FIFO, /* FIFO queue discipline */ + THREAD_QUEUE_DISCIPLINE_PRIORITY /* PRIORITY queue discipline */ } Thread_queue_Disciplines; /* @@ -51,6 +51,7 @@ typedef struct { boolean sync; /* alloc/dealloc critical section */ Thread_queue_Disciplines discipline; /* queue discipline */ States_Control state; /* state of threads on Thread_q */ + unsigned32 timeout_status; } Thread_queue_Control; /* @@ -80,7 +81,7 @@ STATIC INLINE boolean _Thread_queue_Is_reverse_search ( Priority_Control the_priority ); -#include <rtems/tqdata.inl> +#include <rtems/core/tqdata.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/userext.h b/c/src/exec/score/headers/userext.h index 56fae9b7db..2808b3566e 100644 --- a/c/src/exec/score/headers/userext.h +++ b/c/src/exec/score/headers/userext.h @@ -2,7 +2,7 @@ * * This include file contains all information about user extensions. This * Handler provides mechanisms which can be used to initialize and manipulate - * all RTEMS user extensions. + * all user extensions. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,23 +15,89 @@ * $Id$ */ -#ifndef __RTEMS_USER_EXTENSIONS_h -#define __RTEMS_USER_EXTENSIONS_h +#ifndef __USER_EXTENSIONS_h +#define __USER_EXTENSIONS_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/config.h> -#include <rtems/thread.h> +#include <rtems/core/interr.h> +#include <rtems/core/chain.h> +#include <rtems/core/thread.h> + +/* + * The following records defines the User Extension Table. + * This table defines the application dependent routines which + * are invoked at critical points in the life of each thread and + * the system as a whole. + */ + +typedef void User_extensions_routine; + +typedef boolean ( *User_extensions_thread_create_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_delete_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_start_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_restart_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_switch_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine (*User_extensions_thread_post_switch_extension)( + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_begin_extension )( + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_exitted_extension )( + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_fatal_extension )( + Internal_errors_Source /* the_source */, + boolean /* is_internal */, + unsigned32 /* the_error */ + ); + + +typedef struct { + User_extensions_thread_create_extension thread_create; + User_extensions_thread_start_extension thread_start; + User_extensions_thread_restart_extension thread_restart; + User_extensions_thread_delete_extension thread_delete; + User_extensions_thread_switch_extension thread_switch; + User_extensions_thread_post_switch_extension thread_post_switch; + User_extensions_thread_begin_extension thread_begin; + User_extensions_thread_exitted_extension thread_exitted; + User_extensions_fatal_extension fatal; +} User_extensions_Table; /* * The following is used to manage each user extension set. */ typedef struct { - Chain_Node Node; - rtems_extensions_table Callouts; + Chain_Node Node; + User_extensions_Table Callouts; } User_extensions_Control; /* @@ -57,7 +123,7 @@ EXTERN Chain_Control _User_extensions_List; */ STATIC INLINE void _User_extensions_Handler_initialization ( - rtems_extensions_table *initial_extensions + User_extensions_Table *initial_extensions ); /* @@ -70,7 +136,19 @@ STATIC INLINE void _User_extensions_Handler_initialization ( STATIC INLINE void _User_extensions_Add_set ( User_extensions_Control *the_extension, - rtems_extensions_table *extension_table + User_extensions_Table *extension_table +); + +/* + * _User_extensions_Add_API_set + * + * DESCRIPTION: + * + * This routine is used to add an API extension set to the active list. + */ + +STATIC INLINE void _User_extensions_Add_API_set ( + User_extensions_Control *the_extension ); /* @@ -86,59 +164,59 @@ STATIC INLINE void _User_extensions_Remove_set ( ); /* - * _User_extensions_Task_create + * _User_extensions_Thread_create * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_create directive. + * the thread creation operate. */ -STATIC INLINE void _User_extensions_Task_create ( +boolean _User_extensions_Thread_create ( Thread_Control *the_thread ); /* - * _User_extensions_Task_delete + * _User_extensions_Thread_delete * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_delete directive. + * the thread deletion operation. */ -STATIC INLINE void _User_extensions_Task_delete ( +void _User_extensions_Thread_delete ( Thread_Control *the_thread ); /* - * _User_extensions_Task_start + * _User_extensions_Thread_start * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_start directive. + * the thread start operation. */ -STATIC INLINE void _User_extensions_Task_start ( +void _User_extensions_Thread_start ( Thread_Control *the_thread ); /* - * _User_extensions_Task_restart + * _User_extensions_Thread_restart * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_restart directive. + * the thread restart operation. */ -STATIC INLINE void _User_extensions_Task_restart ( +void _User_extensions_Thread_restart ( Thread_Control *the_thread ); /* - * _User_extensions_Task_switch + * _User_extensions_Thread_switch * * DESCRIPTION: * @@ -146,47 +224,49 @@ STATIC INLINE void _User_extensions_Task_restart ( * is invoked when a context switch occurs. */ -STATIC INLINE void _User_extensions_Task_switch ( +STATIC INLINE void _User_extensions_Thread_switch ( Thread_Control *executing, Thread_Control *heir ); /* - * _User_extensions_Task_begin + * _User_extensions_Thread_post_switch * * DESCRIPTION: * - * This routine is used to invoke the user extension which - * is invoked when a task begins. + * This routine is used to invoke the user extension which is invoked + * after a context switch occurs (i.e. we are running in the context + * of the new thread). */ - -STATIC INLINE void _User_extensions_Task_begin ( + +STATIC INLINE void _User_extensions_Thread_post_switch ( Thread_Control *executing ); + /* - * _User_extensions_Task_exitted + * _User_extensions_Thread_begin * * DESCRIPTION: * * This routine is used to invoke the user extension which - * is invoked when a task exits. + * is invoked when a thread begins. */ -STATIC INLINE void _User_extensions_Task_exitted ( +void _User_extensions_Thread_begin ( Thread_Control *executing ); /* - * _User_extensions_Task_exitted + * _User_extensions_Thread_exitted * * DESCRIPTION: * * This routine is used to invoke the user extension which - * is invoked when a task exits. + * is invoked when a thread exits. */ -STATIC INLINE void _User_extensions_Task_exitted ( +void _User_extensions_Thread_exitted ( Thread_Control *executing ); @@ -195,15 +275,17 @@ STATIC INLINE void _User_extensions_Task_exitted ( * * DESCRIPTION: * - * This routine is used to invoke the user extension for - * the rtems_fatal_error_occurred directive. + * This routine is used to invoke the user extension invoked + * when a fatal error occurs. */ -STATIC INLINE void _User_extensions_Fatal ( - unsigned32 the_error +void _User_extensions_Fatal ( + Internal_errors_Source the_source, + boolean is_internal, + unsigned32 the_error ); -#include <rtems/userext.inl> +#include <rtems/core/userext.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/watchdog.h b/c/src/exec/score/headers/watchdog.h index 70de7018dd..7e871c8881 100644 --- a/c/src/exec/score/headers/watchdog.h +++ b/c/src/exec/score/headers/watchdog.h @@ -15,29 +15,29 @@ * $Id$ */ -#ifndef __RTEMS_WATCHDOG_h -#define __RTEMS_WATCHDOG_h +#ifndef __WATCHDOG_h +#define __WATCHDOG_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/object.h> +#include <rtems/core/object.h> /* * The following type defines the control block used to manage * intervals. */ -typedef unsigned32 rtems_interval; +typedef unsigned32 Watchdog_Interval; /* - * The following types define a pointer to a watchdog/timer service routine. + * The following types define a pointer to a watchdog service routine. */ -typedef void rtems_timer_service_routine; +typedef void Watchdog_Service_routine; -typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( +typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )( Objects_Id, void * ); @@ -46,7 +46,7 @@ typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( * Constant for indefinite wait. (actually an illegal interval) */ -#define RTEMS_NO_TIMEOUT 0 +#define WATCHDOG_NO_TIMEOUT 0 /* * The following enumerated type details the modes in which the @@ -92,9 +92,9 @@ typedef enum { typedef struct { Chain_Node Node; Watchdog_States state; - rtems_interval initial; - rtems_interval delta_interval; - rtems_timer_service_routine_entry routine; + Watchdog_Interval initial; + Watchdog_Interval delta_interval; + Watchdog_Service_routine_entry routine; Objects_Id id; void *user_data; } Watchdog_Control; @@ -140,7 +140,7 @@ void _Watchdog_Handler_initialization( void ); STATIC INLINE void _Watchdog_Initialize( Watchdog_Control *the_watchdog, - rtems_timer_service_routine_entry routine, + Watchdog_Service_routine_entry routine, Objects_Id id, void *user_data ); @@ -238,7 +238,7 @@ STATIC INLINE void _Watchdog_Tickle_seconds( void ); STATIC INLINE void _Watchdog_Insert_ticks( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ); @@ -256,7 +256,7 @@ STATIC INLINE void _Watchdog_Insert_ticks( STATIC INLINE void _Watchdog_Insert_seconds( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ); @@ -273,7 +273,7 @@ STATIC INLINE void _Watchdog_Insert_seconds( STATIC INLINE void _Watchdog_Adjust_seconds( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ); /* @@ -288,7 +288,7 @@ STATIC INLINE void _Watchdog_Adjust_seconds( STATIC INLINE void _Watchdog_Adjust_ticks( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ); /* @@ -374,7 +374,7 @@ STATIC INLINE Watchdog_Control *_Watchdog_Last( void _Watchdog_Adjust ( Chain_Control *header, Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ); /* @@ -408,7 +408,7 @@ void _Watchdog_Tickle ( Chain_Control *header ); -#include <rtems/watchdog.inl> +#include <rtems/core/watchdog.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/headers/wkspace.h b/c/src/exec/score/headers/wkspace.h index 7050be6953..a262761d68 100644 --- a/c/src/exec/score/headers/wkspace.h +++ b/c/src/exec/score/headers/wkspace.h @@ -1,8 +1,8 @@ /* wkspace.h * - * This include file contains information related to the RTEMS + * This include file contains information related to the * RAM Workspace. This Handler provides mechanisms which can be used to - * define, initialize and manipulate the RTEMS workspace. + * define, initialize and manipulate the workspace. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,19 +15,18 @@ * $Id$ */ -#ifndef __RTEMS_WORKSPACE_h -#define __RTEMS_WORKSPACE_h +#ifndef __WORKSPACE_h +#define __WORKSPACE_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/heap.h> -#include <rtems/fatal.h> -#include <rtems/status.h> +#include <rtems/core/heap.h> +#include <rtems/core/interr.h> /* - * The following is used to manage the RTEMS Workspace. + * The following is used to manage the Workspace. * */ @@ -67,8 +66,7 @@ STATIC INLINE void *_Workspace_Allocate( * * This routine returns the address of a block of memory of size * bytes. If a block of the appropriate size cannot be allocated - * from the workspace, then the rtems_fatal_error_occurred directive - * is invoked. + * from the workspace, then the internal error handler is invoked. */ void *_Workspace_Allocate_or_fatal_error( @@ -89,7 +87,7 @@ STATIC INLINE boolean _Workspace_Free( void *block ); -#include <rtems/wkspace.inl> +#include <rtems/core/wkspace.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/address.h b/c/src/exec/score/include/rtems/score/address.h index 0abd113f63..4877206801 100644 --- a/c/src/exec/score/include/rtems/score/address.h +++ b/c/src/exec/score/include/rtems/score/address.h @@ -52,21 +52,6 @@ STATIC INLINE void *_Addresses_Subtract_offset( ); /* - * _Addresses_Add - * - * DESCRIPTION: - * - * This function is used to add two addresses. It returns the - * resulting address. This address is typically converted to an - * access type before being used further. - */ - -STATIC INLINE void *_Addresses_Add ( - void *left, - void *right -); - -/* * _Addresses_Subtract * * DESCRIPTION: @@ -112,7 +97,7 @@ STATIC INLINE boolean _Addresses_Is_in_range ( void *limit ); -#include <rtems/address.inl> +#include <rtems/core/address.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/chain.h b/c/src/exec/score/include/rtems/score/chain.h index 06cc47cc65..35ac4dfa80 100644 --- a/c/src/exec/score/include/rtems/score/chain.h +++ b/c/src/exec/score/include/rtems/score/chain.h @@ -21,7 +21,7 @@ extern "C" { #endif -#include <rtems/address.h> +#include <rtems/core/address.h> /* * This is used to manage each element (node) which is placed @@ -422,7 +422,7 @@ STATIC INLINE boolean _Chain_Is_null_node( Chain_Node *the_node ); -#include <rtems/chain.inl> +#include <rtems/core/chain.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/context.h b/c/src/exec/score/include/rtems/score/context.h index 9b8ee92b04..58e497ae88 100644 --- a/c/src/exec/score/include/rtems/score/context.h +++ b/c/src/exec/score/include/rtems/score/context.h @@ -20,7 +20,7 @@ extern "C" { #endif -#include <rtems/cpu.h> +#include <rtems/core/cpu.h> /* * The following constant defines the number of bytes required diff --git a/c/src/exec/score/include/rtems/score/coremutex.h b/c/src/exec/score/include/rtems/score/coremutex.h new file mode 100644 index 0000000000..0682bbc1ea --- /dev/null +++ b/c/src/exec/score/include/rtems/score/coremutex.h @@ -0,0 +1,247 @@ +/* mutex.h + * + * This include file contains all the constants and structures associated + * with the Mutex Handler. A mutex is an enhanced version of the standard + * Dijkstra binary semaphore used to provide synchronization and mutual + * exclusion capabilities. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __RTEMS_CORE_MUTEX_h +#define __RTEMS_CORE_MUTEX_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/priority.h> +#include <rtems/core/watchdog.h> + +/* + * The following type defines the callout which the API provides + * to support global/multiprocessor operations on mutexes. + */ + +typedef void ( *CORE_mutex_API_mp_support_callout )( + Thread_Control *, + Objects_Id + ); + +/* + * Blocking disciplines for a mutex. + */ + +typedef enum { + CORE_MUTEX_DISCIPLINES_FIFO, + CORE_MUTEX_DISCIPLINES_PRIORITY, + CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT, + CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING +} CORE_mutex_Disciplines; + +/* + * Mutex handler return statuses. + */ + +typedef enum { + CORE_MUTEX_STATUS_SUCCESSFUL, + CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT, + CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED, + CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE, + CORE_MUTEX_WAS_DELETED, + CORE_MUTEX_TIMEOUT +} CORE_mutex_Status; + +/* + * Locked and unlocked values + */ + +#define CORE_MUTEX_UNLOCKED 1 +#define CORE_MUTEX_LOCKED 0 + +/* + * The following defines the control block used to manage the + * attributes of each mutex. + */ + +typedef struct { + boolean allow_nesting; + CORE_mutex_Disciplines discipline; + Priority_Control priority_ceiling; +} CORE_mutex_Attributes; + +/* + * The following defines the control block used to manage each mutex. + */ + +typedef struct { + Thread_queue_Control Wait_queue; + CORE_mutex_Attributes Attributes; + unsigned32 lock; + unsigned32 nest_count; + Thread_Control *holder; + Objects_Id holder_id; +} CORE_mutex_Control; + +/* + * _CORE_mutex_Initialize + * + * DESCRIPTION: + * + * This routine initializes the mutex based on the parameters passed. + */ + +void _CORE_mutex_Initialize( + CORE_mutex_Control *the_mutex, + Objects_Classes the_class, + CORE_mutex_Attributes *the_mutex_attributes, + unsigned32 initial_lock, + Thread_queue_Extract_callout proxy_extract_callout +); + +/* + * _CORE_mutex_Seize + * + * DESCRIPTION: + * + * This routine attempts to receive a unit from the_mutex. + * If a unit is available or if the wait flag is FALSE, then the routine + * returns. Otherwise, the calling task is blocked until a unit becomes + * available. + */ + +void _CORE_mutex_Seize( + CORE_mutex_Control *the_mutex, + Objects_Id id, + boolean wait, + Watchdog_Interval timeout +); + +/* + * _CORE_mutex_Surrender + * + * DESCRIPTION: + * + * This routine frees a unit to the mutex. If a task was blocked waiting for + * a unit from this mutex, then that task will be readied and the unit + * given to that task. Otherwise, the unit will be returned to the mutex. + */ + +CORE_mutex_Status _CORE_mutex_Surrender( + CORE_mutex_Control *the_mutex, + Objects_Id id, + CORE_mutex_API_mp_support_callout api_mutex_mp_support +); + +/* + * _CORE_mutex_Flush + * + * DESCRIPTION: + * + * This routine assists in the deletion of a mutex by flushing the associated + * wait queue. + */ + +void _CORE_mutex_Flush( + CORE_mutex_Control *the_mutex, + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status +); + +/* + * _CORE_mutex_Is_locked + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex specified is locked and FALSE + * otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_locked( + CORE_mutex_Control *the_mutex +); + +/* + * _CORE_mutex_Is_fifo + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is FIFO and FALSE + * otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_fifo( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_priority + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is PRIORITY and + * FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_inherit_priority + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is + * INHERIT_PRIORITY and FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_inherit_priority( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_priority_ceiling + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex's wait discipline is + * PRIORITY_CEILING and FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority_ceiling( + CORE_mutex_Attributes *the_attribute +); + +/* + * _CORE_mutex_Is_nesting_allowed + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex allows a task to obtain a + * semaphore more than once and nest. + */ + +STATIC INLINE boolean _CORE_mutex_Is_nesting_allowed( + CORE_mutex_Attributes *the_attribute +); + +#include <rtems/core/coremutex.inl> + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ + diff --git a/c/src/exec/score/include/rtems/score/coresem.h b/c/src/exec/score/include/rtems/score/coresem.h new file mode 100644 index 0000000000..0fcd8cd0b9 --- /dev/null +++ b/c/src/exec/score/include/rtems/score/coresem.h @@ -0,0 +1,179 @@ +/* core_sem.h + * + * This include file contains all the constants and structures associated + * with the Counting Semaphore Handler. A counting semaphore is the + * standard Dijkstra binary semaphore used to provide synchronization + * and mutual exclusion capabilities. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __RTEMS_CORE_COUNTING_SEMAPHORE_h +#define __RTEMS_CORE_COUNTING_SEMAPHORE_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/priority.h> +#include <rtems/core/watchdog.h> + +/* + * The following type defines the callout which the API provides + * to support global/multiprocessor operations on semaphores. + */ + +typedef void ( *CORE_semaphore_API_mp_support_callout )( + Thread_Control *, + Objects_Id + ); + +/* + * Blocking disciplines for a semaphore. + */ + +typedef enum { + CORE_SEMAPHORE_DISCIPLINES_FIFO, + CORE_SEMAPHORE_DISCIPLINES_PRIORITY +} CORE_semaphore_Disciplines; + +/* + * Core Semaphore handler return statuses. + */ + +typedef enum { + CORE_SEMAPHORE_STATUS_SUCCESSFUL, + CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT, + CORE_SEMAPHORE_WAS_DELETED, + CORE_SEMAPHORE_TIMEOUT +} CORE_semaphore_Status; + +/* + * The following defines the control block used to manage the + * attributes of each semaphore. + */ + +typedef struct { + CORE_semaphore_Disciplines discipline; +} CORE_semaphore_Attributes; + +/* + * The following defines the control block used to manage each + * counting semaphore. + */ + +typedef struct { + Thread_queue_Control Wait_queue; + CORE_semaphore_Attributes Attributes; + unsigned32 count; +} CORE_semaphore_Control; + +/* + * _CORE_semaphore_Initialize + * + * DESCRIPTION: + * + * This routine initializes the semaphore based on the parameters passed. + */ + +void _CORE_semaphore_Initialize( + CORE_semaphore_Control *the_semaphore, + Objects_Classes the_class, + CORE_semaphore_Attributes *the_semaphore_attributes, + unsigned32 initial_value, + Thread_queue_Extract_callout proxy_extract_callout +); + +/* + * _CORE_semaphore_Seize + * + * DESCRIPTION: + * + * This routine attempts to receive a unit from the_semaphore. + * If a unit is available or if the wait flag is FALSE, then the routine + * returns. Otherwise, the calling task is blocked until a unit becomes + * available. + */ + +void _CORE_semaphore_Seize( + CORE_semaphore_Control *the_semaphore, + Objects_Id id, + boolean wait, + Watchdog_Interval timeout +); + +/* + * _CORE_semaphore_Surrender + * + * DESCRIPTION: + * + * This routine frees a unit to the semaphore. If a task was blocked waiting + * for a unit from this semaphore, then that task will be readied and the unit + * given to that task. Otherwise, the unit will be returned to the semaphore. + */ + +CORE_semaphore_Status _CORE_semaphore_Surrender( + CORE_semaphore_Control *the_semaphore, + Objects_Id id, + CORE_semaphore_API_mp_support_callout api_semaphore_mp_support +); + +/* + * _CORE_semaphore_Flush + * + * DESCRIPTION: + * + * This routine assists in the deletion of a semaphore by flushing the + * associated wait queue. + */ + +void _CORE_semaphore_Flush( + CORE_semaphore_Control *the_semaphore, + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status +); + +/* + * _CORE_semaphore_Get_count + * + * DESCRIPTION: + * + * This routine returns the current count associated with the semaphore. + */ + +STATIC INLINE unsigned32 _CORE_semaphore_Get_count( + CORE_semaphore_Control *the_semaphore +); + +/* + * _CORE_semaphore_Is_priority + * + * DESCRIPTION: + * + * This function returns TRUE if the priority attribute is + * enabled in the attribute_set and FALSE otherwise. + */ + +STATIC INLINE boolean _CORE_semaphore_Is_priority( + CORE_semaphore_Attributes *the_attribute +); + +#include <rtems/core/coresem.inl> + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ + diff --git a/c/src/exec/score/include/rtems/score/heap.h b/c/src/exec/score/include/rtems/score/heap.h index 9eb348a760..bf4a8dde6e 100644 --- a/c/src/exec/score/include/rtems/score/heap.h +++ b/c/src/exec/score/include/rtems/score/heap.h @@ -386,7 +386,7 @@ STATIC INLINE unsigned32 _Heap_Build_flag ( unsigned32 in_use_flag ); -#include <rtems/heap.inl> +#include <rtems/core/heap.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/interr.h b/c/src/exec/score/include/rtems/score/interr.h new file mode 100644 index 0000000000..c1088a9dff --- /dev/null +++ b/c/src/exec/score/include/rtems/score/interr.h @@ -0,0 +1,93 @@ +/* interr.h + * + * This include file contains constants and prototypes related + * to the Internal Error Handler. + * + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id# + */ + +#ifndef __RTEMS_INTERNAL_ERROR_h +#define __RTEMS_INTERNAL_ERROR_h + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This type lists the possible sources from which an error + * can be reported. + */ + +typedef enum { + INTERNAL_ERROR_CORE, + INTERNAL_ERROR_RTEMS_API +} Internal_errors_Source; + +/* + * A list of errors which are generated internally by the executive core. + */ + +typedef enum { + INTERNAL_ERROR_NO_CONFIGURATION_TABLE, + INTERNAL_ERROR_NO_CPU_TABLE, + INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS, + INTERNAL_ERROR_TOO_LITTLE_WORKSPACE, + INTERNAL_ERROR_WORKSPACE_ALLOCATION, + INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL, + INTERNAL_ERROR_THREAD_EXITTED, + INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION, + INTERNAL_ERROR_INVALID_NODE, + INTERNAL_ERROR_NO_MPCI, + INTERNAL_ERROR_BAD_PACKET, + INTERNAL_ERROR_OUT_OF_PACKETS, + INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS, + INTERNAL_ERROR_OUT_OF_PROXIES, + INTERNAL_ERROR_INVALID_GLOBAL_ID +} Internal_errors_Core_list; + +/* + * This type holds the fatal error information. + */ + +typedef struct { + Internal_errors_Source the_source; + boolean is_internal; + unsigned32 the_error; +} Internal_errors_Information; + +/* + * When a fatal error occurs, the error information is stored here. + */ + +EXTERN Internal_errors_Information Internal_errors_What_happened; + +/* + * _Internal_error_Occurred + * + * DESCRIPTION: + * + * This routine is invoked when the application or the executive itself + * determines that a fatal error has occurred. + */ + +void volatile _Internal_error_Occurred( + Internal_errors_Source the_source, + boolean is_internal, + unsigned32 the_error +); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/c/src/exec/score/include/rtems/score/isr.h b/c/src/exec/score/include/rtems/score/isr.h index 77c3f8663e..4bbc3c7aff 100644 --- a/c/src/exec/score/include/rtems/score/isr.h +++ b/c/src/exec/score/include/rtems/score/isr.h @@ -16,8 +16,8 @@ * $Id$ */ -#ifndef __RTEMS_ISR_h -#define __RTEMS_ISR_h +#ifndef __ISR_h +#define __ISR_h #ifdef __cplusplus extern "C" { @@ -31,24 +31,23 @@ extern "C" { typedef unsigned32 ISR_Level; /* - * The following type defines the control block used to manage - * the vectors. + * The following type defines the type used to manage the vectors. */ -typedef unsigned32 rtems_vector_number; +typedef unsigned32 ISR_Vector_number; /* * Return type for ISR Handler */ -typedef void rtems_isr; +typedef void ISR_Handler; /* * Pointer to an ISR Handler */ -typedef rtems_isr ( *rtems_isr_entry )( - rtems_vector_number +typedef ISR_Handler ( *ISR_Handler_entry )( + ISR_Vector_number ); /* * The following is TRUE if signals have been sent to the currently @@ -65,11 +64,11 @@ EXTERN boolean _ISR_Signals_to_thread_executing; EXTERN unsigned32 _ISR_Nest_level; /* - * The following declares the RTEMS Vector Table. Application - * interrupt service routines are vectored by RTEMS via this table. + * The following declares the Vector Table. Application + * interrupt service routines are vectored by the ISR Handler via this table. */ -EXTERN rtems_isr_entry _ISR_Vector_table[CPU_INTERRUPT_NUMBER_OF_VECTORS]; +EXTERN ISR_Handler_entry _ISR_Vector_table[CPU_INTERRUPT_NUMBER_OF_VECTORS]; /* * _ISR_Handler_initialization @@ -79,7 +78,7 @@ EXTERN rtems_isr_entry _ISR_Vector_table[CPU_INTERRUPT_NUMBER_OF_VECTORS]; * This routine performs the initialization necessary for this handler. */ -STATIC INLINE void _ISR_Handler_initialization ( void ); +void _ISR_Handler_initialization ( void ); /* * _ISR_Disable @@ -154,6 +153,17 @@ STATIC INLINE boolean _ISR_Is_in_progress( void ); _CPU_ISR_install_vector( _vector, _new_handler, _old_handler ) /* + * _ISR_Get_level + * + * DESCRIPTION: + * + * This routine returns the current interrupt level. + */ + +#define _ISR_Get_level() \ + _CPU_ISR_Get_level() + +/* * _ISR_Set_level * * DESCRIPTION: @@ -176,7 +186,7 @@ STATIC INLINE boolean _ISR_Is_in_progress( void ); */ STATIC INLINE boolean _ISR_Is_vector_number_valid ( - rtems_vector_number vector + ISR_Vector_number vector ); /* @@ -197,7 +207,7 @@ STATIC INLINE boolean _ISR_Is_valid_user_handler ( * * DESCRIPTION: * - * This routine is the RTEMS interrupt dispatcher. ALL interrupts + * This routine is the interrupt dispatcher. ALL interrupts * are vectored to this routine so that minimal context can be saved * and setup performed before the application's high-level language * interrupt service routine is invoked. After the application's @@ -229,7 +239,7 @@ void _ISR_Handler( void ); void _ISR_Dispatch( void ); -#include <rtems/isr.inl> +#include <rtems/core/isr.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/mpci.h b/c/src/exec/score/include/rtems/score/mpci.h index ca06dd243b..06dc0015d4 100644 --- a/c/src/exec/score/include/rtems/score/mpci.h +++ b/c/src/exec/score/include/rtems/score/mpci.h @@ -14,20 +14,20 @@ * $Id$ */ -#ifndef __RTEMS_MPCI_h -#define __RTEMS_MPCI_h +#ifndef __MPCI_h +#define __MPCI_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/mppkt.h> -#include <rtems/states.h> -#include <rtems/status.h> -#include <rtems/thread.h> -#include <rtems/threadq.h> -#include <rtems/tqdata.h> -#include <rtems/watchdog.h> +#include <rtems/core/mppkt.h> +#include <rtems/core/states.h> +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/tqdata.h> +#include <rtems/core/watchdog.h> +#include <rtems/core/coresem.h> /* * The following defines the node number used when a broadcast is desired. @@ -45,6 +45,85 @@ extern "C" { #define MPCI_DEFAULT_TIMEOUT 0xFFFFFFFF /* + * The following records define the Multiprocessor Communications + * Interface (MPCI) Table. This table defines the user-provided + * MPCI which is a required part of a multiprocessor system. + * + * For non-blocking local operations that become remote operations, + * we need a timeout. This is a per-driver timeout: default_timeout + */ + +typedef void MPCI_Entry; + +typedef MPCI_Entry ( *MPCI_initialization_entry )( void ); + +typedef MPCI_Entry ( *MPCI_get_packet_entry )( + MP_packet_Prefix ** + ); + +typedef MPCI_Entry ( *MPCI_return_packet_entry )( + MP_packet_Prefix * + ); + +typedef MPCI_Entry ( *MPCI_send_entry )( + unsigned32, + MP_packet_Prefix * + ); + +typedef MPCI_Entry ( *MPCI_receive_entry )( + MP_packet_Prefix ** + ); + +typedef struct { + unsigned32 default_timeout; /* in ticks */ + unsigned32 maximum_packet_size; + MPCI_initialization_entry initialization; + MPCI_get_packet_entry get_packet; + MPCI_return_packet_entry return_packet; + MPCI_send_entry send_packet; + MPCI_receive_entry receive_packet; +} MPCI_Control; + +/* + * The following defines the type for packet processing routines + * invoked by the MPCI Receive server. + */ + +typedef void (*MPCI_Packet_processor)( MP_packet_Prefix * ); + +/* + * This is the core semaphore which the MPCI Receive Server blocks on. + */ + +EXTERN CORE_semaphore_Control _MPCI_Semaphore; +/* + * The following thread queue is used to maintain a list of tasks + * which currently have outstanding remote requests. + */ + +EXTERN Thread_queue_Control _MPCI_Remote_blocked_threads; + +/* + * The following define the internal pointers to the user's + * configuration information. + */ + +EXTERN MPCI_Control *_MPCI_table; + +/* + * The following points to the MPCI Receive Server. + */ + +EXTERN Thread_Control *_MPCI_Receive_server_tcb; + +/* + * The following table contains the process packet routines provided + * by each object that supports MP operations. + */ + +EXTERN MPCI_Packet_processor _MPCI_Packet_processors[MP_PACKET_CLASSES_LAST+1]; + +/* * _MPCI_Handler_initialization * * DESCRIPTION: @@ -52,7 +131,9 @@ extern "C" { * This routine performs the initialization necessary for this handler. */ -void _MPCI_Handler_initialization ( void ); +void _MPCI_Handler_initialization( + MPCI_Control *users_mpci_table +); /* * _MPCI_Initialization @@ -66,6 +147,21 @@ void _MPCI_Handler_initialization ( void ); void _MPCI_Initialization ( void ); /* + * _MPCI_Register_packet_processor + * + * DESCRIPTION: + * + * This routine registers the MPCI packet processor for the + * designated object class. + */ + +void _MPCI_Register_packet_processor( + MP_packet_Classes the_object, + MPCI_Packet_processor the_packet_processor + +); + +/* * _MPCI_Get_packet * * DESCRIPTION: @@ -74,7 +170,7 @@ void _MPCI_Initialization ( void ); * MPCI get packet callout. */ -rtems_packet_prefix *_MPCI_Get_packet ( void ); +MP_packet_Prefix *_MPCI_Get_packet ( void ); /* * _MPCI_Return_packet @@ -86,7 +182,7 @@ rtems_packet_prefix *_MPCI_Get_packet ( void ); */ void _MPCI_Return_packet ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); /* @@ -100,7 +196,7 @@ void _MPCI_Return_packet ( void _MPCI_Send_process_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); /* @@ -112,9 +208,9 @@ void _MPCI_Send_process_packet ( * MPCI send callout. */ -rtems_status_code _MPCI_Send_request_packet ( +unsigned32 _MPCI_Send_request_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet, + MP_packet_Prefix *the_packet, States_Control extra_state ); @@ -129,7 +225,7 @@ rtems_status_code _MPCI_Send_request_packet ( void _MPCI_Send_response_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); /* @@ -141,7 +237,7 @@ void _MPCI_Send_response_packet ( * MPCI receive callout. */ -rtems_packet_prefix *_MPCI_Receive_packet ( void ); +MP_packet_Prefix *_MPCI_Receive_packet ( void ); /* * _MPCI_Process_response @@ -153,15 +249,27 @@ rtems_packet_prefix *_MPCI_Receive_packet ( void ); */ Thread_Control *_MPCI_Process_response ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); -/* - * The following thread queue is used to maintain a list of tasks - * which currently have outstanding remote requests. +/*PAGE + * + * _MPCI_Receive_server + * */ + +void _MPCI_Receive_server( void ); -EXTERN Thread_queue_Control _MPCI_Remote_blocked_threads; +/*PAGE + * + * _MPCI_Announce + * + * DESCRIPTION: + * + * XXX + */ + +void _MPCI_Announce ( void ); #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/mppkt.h b/c/src/exec/score/include/rtems/score/mppkt.h index d63d587fca..32cbc7e0e9 100644 --- a/c/src/exec/score/include/rtems/score/mppkt.h +++ b/c/src/exec/score/include/rtems/score/mppkt.h @@ -1,8 +1,10 @@ /* mppkt.h * * This package is the specification for the Packet Handler. - * This handler defines the basic RTEMS packet and provides + * This handler defines the basic packet and provides * mechanisms to utilize packets based on this prefix. + * Packets are the fundamental basis for messages passed between + * nodes in an MP system. * * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. @@ -16,20 +18,19 @@ * $Id$ */ -#ifndef __RTEMS_MP_PACKET_h -#define __RTEMS_MP_PACKET_h +#ifndef __MP_PACKET_h +#define __MP_PACKET_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/object.h> -#include <rtems/priority.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/priority.h> +#include <rtems/core/watchdog.h> /* - * The following enumerated type defines the packet classes - * supported by RTEMS. + * The following enumerated type defines the packet classes. * * NOTE: In general, each class corresponds to a manager * which supports global operations. Each manager @@ -37,55 +38,55 @@ extern "C" { */ typedef enum { - RTEMS_MP_PACKET_INTERNAL_THREADS = 0, - RTEMS_MP_PACKET_TASKS = 1, - RTEMS_MP_PACKET_MESSAGE_QUEUE = 2, - RTEMS_MP_PACKET_SEMAPHORE = 3, - RTEMS_MP_PACKET_PARTITION = 4, - RTEMS_MP_PACKET_REGION = 5, - RTEMS_MP_PACKET_EVENT = 6, - RTEMS_MP_PACKET_SIGNAL = 7 -} rtems_mp_packet_classes; - -#define MP_PACKET_CLASSES_FIRST RTEMS_MP_PACKET_INTERNAL_THREADS -#define MP_PACKET_CLASSES_LAST RTEMS_MP_PACKET_SIGNAL + MP_PACKET_INTERNAL_THREADS = 0, + MP_PACKET_TASKS = 1, + MP_PACKET_MESSAGE_QUEUE = 2, + MP_PACKET_SEMAPHORE = 3, + MP_PACKET_PARTITION = 4, + MP_PACKET_REGION = 5, + MP_PACKET_EVENT = 6, + MP_PACKET_SIGNAL = 7 +} MP_packet_Classes; + +#define MP_PACKET_CLASSES_FIRST MP_PACKET_INTERNAL_THREADS +#define MP_PACKET_CLASSES_LAST MP_PACKET_SIGNAL /* * The following record contains the prefix for every packet - * passed between RTEMS nodes. + * passed between nodes in an MP system. * * NOTE: This structure is padded to insure that anything * following it is on a 16 byte boundary. This is * the most stringent structure alignment rule - * the RTEMS project has encountered yet (i960CA). + * encountered yet (i960CA). */ typedef struct { - rtems_mp_packet_classes the_class; + MP_packet_Classes the_class; Objects_Id id; Objects_Id source_tid; Priority_Control source_priority; - rtems_status_code return_code; + unsigned32 return_code; unsigned32 length; unsigned32 to_convert; - rtems_interval timeout; -} rtems_packet_prefix; + Watchdog_Interval timeout; +} MP_packet_Prefix; /* * An MPCI must support packets of at least this size. */ -#define RTEMS_MINIMUM_PACKET_SIZE 64 +#define MP_PACKET_MINIMUM_PACKET_SIZE 64 /* * The following constant defines the number of unsigned32's * in a packet which must be converted to native format in a * heterogeneous system. In packets longer than - * RTEMS_MINIMUN_HETERO_CONVERSION unsigned32's, some of the "extra" data + * MP_PACKET_MINIMUN_HETERO_CONVERSION unsigned32's, some of the "extra" data * may a user message buffer which is not automatically endian swapped. */ -#define RTEMS_MINIMUN_HETERO_CONVERSION ( sizeof( rtems_packet_prefix ) / 4 ) +#define MP_PACKET_MINIMUN_HETERO_CONVERSION ( sizeof( MP_packet_Prefix ) / 4 ) /* * _Mp_packet_Is_valid_packet_class @@ -97,7 +98,7 @@ typedef struct { */ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( - rtems_mp_packet_classes the_packet_class + MP_packet_Classes the_packet_class ); /* @@ -110,10 +111,10 @@ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( */ STATIC INLINE boolean _Mp_packet_Is_null ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ); -#include <rtems/mppkt.inl> +#include <rtems/core/mppkt.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/object.h b/c/src/exec/score/include/rtems/score/object.h index b1d422d3d4..3da299e95f 100644 --- a/c/src/exec/score/include/rtems/score/object.h +++ b/c/src/exec/score/include/rtems/score/object.h @@ -1,8 +1,9 @@ /* object.h * * This include file contains all the constants and structures associated - * with the RTEMS Object Handler. This Handler provides mechanisms which - * can be used to initialize and manipulate all RTEMS objects. + * with the Object Handler. This Handler provides mechanisms which + * can be used to initialize and manipulate all objects which have + * ids. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,14 +16,14 @@ * $Id$ */ -#ifndef __RTEMS_OBJECTS_h -#define __RTEMS_OBJECTS_h +#ifndef __OBJECTS_h +#define __OBJECTS_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/chain.h> +#include <rtems/core/chain.h> /* * The following type defines the control block used to manage @@ -142,6 +143,7 @@ typedef struct { */ EXTERN unsigned32 _Objects_Local_node; +EXTERN unsigned32 _Objects_Maximum_nodes; /* * The following is the list of information blocks for each object @@ -164,23 +166,23 @@ EXTERN Objects_Information * The following define the constants which may be used in name searches. */ -#define RTEMS_SEARCH_ALL_NODES 0 -#define RTEMS_SEARCH_OTHER_NODES 0x7FFFFFFE -#define RTEMS_SEARCH_LOCAL_NODE 0x7FFFFFFF -#define RTEMS_WHO_AM_I 0 +#define OBJECTS_SEARCH_ALL_NODES 0 +#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE +#define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF +#define OBJECTS_WHO_AM_I 0 /* * Parameters and return id's for _Objects_Get_next */ -#define RTEMS_OBJECT_ID_INITIAL_INDEX (0) -#define RTEMS_OBJECT_ID_FINAL_INDEX (0xffff) +#define OBJECTS_ID_INITIAL_INDEX (0) +#define OBJECTS_ID_FINAL_INDEX (0xffff) -#define RTEMS_OBJECT_ID_INITIAL(node) (_Objects_Build_id( \ - OBJECTS_NO_CLASS, \ - node, \ - RTEMS_OBJECT_ID_INITIAL_INDEX)) -#define RTEMS_OBJECT_ID_FINAL ((Objects_Id)~0) +#define OBJECTS_ID_INITIAL(node) (_Objects_Build_id( \ + OBJECTS_NO_CLASS, \ + node, \ + OBJECTS_ID_INITIAL_INDEX)) +#define OBJECTS_ID_FINAL ((Objects_Id)~0) /* * _Objects_Handler_initialization @@ -193,6 +195,7 @@ EXTERN Objects_Information void _Objects_Handler_initialization( unsigned32 node, + unsigned32 maximum_nodes, unsigned32 maximum_global_objects ); @@ -303,7 +306,16 @@ boolean _Objects_Compare_name_raw( * */ -rtems_status_code _Objects_Name_to_id( +typedef enum { + OBJECTS_SUCCESSFUL, + OBJECTS_INVALID_NAME, + OBJECTS_INVALID_NODE +} Objects_Name_to_id_errors; + +#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_SUCCESSFUL +#define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE + +Objects_Name_to_id_errors _Objects_Name_to_id( Objects_Information *information, Objects_Name name, unsigned32 node, @@ -378,7 +390,7 @@ STATIC INLINE Objects_Id _Objects_Build_id( ); /* - * rtems_get_class + * _Objects_Get_class * * DESCRIPTION: * @@ -386,12 +398,12 @@ STATIC INLINE Objects_Id _Objects_Build_id( * */ -STATIC INLINE Objects_Classes rtems_get_class( +STATIC INLINE Objects_Classes _Objects_Get_class( Objects_Id id ); /* - * rtems_get_node + * _Objects_Get_node * * DESCRIPTION: * @@ -399,12 +411,12 @@ STATIC INLINE Objects_Classes rtems_get_class( * */ -STATIC INLINE unsigned32 rtems_get_node( +STATIC INLINE unsigned32 _Objects_Get_node( Objects_Id id ); /* - * rtems_get_index + * _Objects_Get_index * * DESCRIPTION: * @@ -412,7 +424,7 @@ STATIC INLINE unsigned32 rtems_get_node( * */ -STATIC INLINE unsigned32 rtems_get_index( +STATIC INLINE unsigned32 _Objects_Get_index( Objects_Id id ); @@ -532,7 +544,7 @@ STATIC INLINE void _Objects_Close( Objects_Control *the_object ); -#include <rtems/object.inl> +#include <rtems/core/object.inl> #include <rtems/objectmp.h> #ifdef __cplusplus diff --git a/c/src/exec/score/include/rtems/score/objectmp.h b/c/src/exec/score/include/rtems/score/objectmp.h index b15d5cbb43..cef5c6879d 100644 --- a/c/src/exec/score/include/rtems/score/objectmp.h +++ b/c/src/exec/score/include/rtems/score/objectmp.h @@ -42,6 +42,8 @@ typedef struct { */ void _Objects_MP_Handler_initialization ( + unsigned32 node, + unsigned32 maximum_nodes, unsigned32 maximum_global_objects ); @@ -140,7 +142,7 @@ void _Objects_MP_Close ( * object with that name if one is found. */ -rtems_status_code _Objects_MP_Global_name_search ( +Objects_Name_to_id_errors _Objects_MP_Global_name_search ( Objects_Information *information, Objects_Name the_name, unsigned32 nodes_to_search, @@ -171,6 +173,7 @@ void _Objects_MP_Is_remote ( * inactive global object control blocks. */ +EXTERN unsigned32 _Objects_MP_Maximum_global_objects; EXTERN Chain_Control _Objects_MP_Inactive_global_objects; #include <rtems/objectmp.inl> diff --git a/c/src/exec/score/include/rtems/score/priority.h b/c/src/exec/score/include/rtems/score/priority.h index 44397e7a8a..8f681c0ce1 100644 --- a/c/src/exec/score/include/rtems/score/priority.h +++ b/c/src/exec/score/include/rtems/score/priority.h @@ -2,7 +2,7 @@ * * This include file contains all thread priority manipulation routines. * This Handler provides mechanisms which can be used to - * initialize and manipulate RTEMS priorities. + * initialize and manipulate thread priorities. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,8 +15,8 @@ * $Id$ */ -#ifndef __RTEMS_PRIORITY_h -#define __RTEMS_PRIORITY_h +#ifndef __PRIORITY_h +#define __PRIORITY_h #ifdef __cplusplus extern "C" { @@ -31,8 +31,8 @@ extern "C" { typedef unsigned32 Priority_Control; -#define RTEMS_MINIMUM_PRIORITY 1 /* highest thread priority */ -#define RTEMS_MAXIMUM_PRIORITY 255 /* lowest thread priority */ +#define PRIORITY_MINIMUM 0 /* highest thread priority */ +#define PRIORITY_MAXIMUM 255 /* lowest thread priority */ /* * The following record defines the information associated with @@ -62,12 +62,6 @@ EXTERN volatile Priority_Bit_map_control _Priority_Major_bit_map; EXTERN Priority_Bit_map_control _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT; /* - * The following constants are useful when manipulating priority. - */ - -#define RTEMS_CURRENT_PRIORITY 0 /* obtain current priority */ - -/* * The definition of the Priority_Bit_map_control type is CPU dependent. * */ @@ -185,7 +179,7 @@ STATIC INLINE boolean _Priority_Is_group_empty ( Priority_Control the_priority ); -#include <rtems/priority.inl> +#include <rtems/core/priority.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/stack.h b/c/src/exec/score/include/rtems/score/stack.h index a0fce1ef04..2a41bcf89f 100644 --- a/c/src/exec/score/include/rtems/score/stack.h +++ b/c/src/exec/score/include/rtems/score/stack.h @@ -15,8 +15,8 @@ * $Id$ */ -#ifndef __RTEMS_STACK_h -#define __RTEMS_STACK_h +#ifndef __STACK_h +#define __STACK_h #ifdef __cplusplus extern "C" { @@ -27,7 +27,7 @@ extern "C" { * thread must exceed. */ -#define RTEMS_MINIMUM_STACK_SIZE CPU_STACK_MINIMUM_SIZE +#define STACK_MINIMUM_SIZE CPU_STACK_MINIMUM_SIZE /* * The following defines the control block used to manage each stack. @@ -85,7 +85,7 @@ STATIC INLINE unsigned32 _Stack_Adjust_size ( unsigned32 size ); -#include <rtems/stack.inl> +#include <rtems/core/stack.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/states.h b/c/src/exec/score/include/rtems/score/states.h index 56f67ecc49..3f7c4a7e99 100644 --- a/c/src/exec/score/include/rtems/score/states.h +++ b/c/src/exec/score/include/rtems/score/states.h @@ -1,6 +1,6 @@ /* states.h * - * This include file contains all RTEMS state information. + * This include file contains thread execution state information. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -43,13 +43,15 @@ typedef unsigned32 States_Control; #define STATES_WAITING_FOR_MESSAGE 0x0040 /* wait for message */ #define STATES_WAITING_FOR_EVENT 0x0080 /* wait for event */ #define STATES_WAITING_FOR_SEMAPHORE 0x0100 /* wait for semaphore */ -#define STATES_WAITING_FOR_TIME 0x0200 /* wait for specific TOD */ -#define STATES_WAITING_FOR_RPC_REPLY 0x0400 /* wait for rpc reply */ -#define STATES_WAITING_FOR_PERIOD 0x0800 /* rate monotonic delay */ +#define STATES_WAITING_FOR_MUTEX 0x0200 /* wait for mutex */ +#define STATES_WAITING_FOR_TIME 0x0400 /* wait for specific TOD */ +#define STATES_WAITING_FOR_RPC_REPLY 0x0800 /* wait for rpc reply */ +#define STATES_WAITING_FOR_PERIOD 0x1000 /* rate monotonic delay */ #define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_BUFFER | \ STATES_WAITING_FOR_SEGMENT | \ STATES_WAITING_FOR_MESSAGE | \ + STATES_WAITING_FOR_MUTEX | \ STATES_WAITING_FOR_SEMAPHORE ) #define STATES_WAITING_ON_THREAD_QUEUE \ @@ -221,6 +223,19 @@ STATIC INLINE boolean _States_Is_waiting_for_event ( ); /* + * _States_Is_waiting_for_mutex + * + * DESCRIPTION: + * + * This function returns TRUE if the WAITING_FOR_MUTEX state + * is set in the_states, and FALSE otherwise. + */ + +STATIC INLINE boolean _States_Is_waiting_for_mutex ( + States_Control the_states +); + +/* * _States_Is_waiting_for_semaphore * * DESCRIPTION: @@ -327,7 +342,7 @@ STATIC INLINE boolean _States_Are_set ( States_Control mask ); -#include <rtems/states.inl> +#include <rtems/core/states.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/sysstate.h b/c/src/exec/score/include/rtems/score/sysstate.h index 511a26cefc..b0ace61f98 100644 --- a/c/src/exec/score/include/rtems/score/sysstate.h +++ b/c/src/exec/score/include/rtems/score/sysstate.h @@ -40,12 +40,31 @@ typedef enum { #define SYSTEM_STATE_CODES_LAST SYSTEM_STATE_FAILED /* + * The following variable indicates whether or not this is + * an multiprocessing system. + */ + +EXTERN boolean _System_state_Is_multiprocessing; + +/* * The following variable contains the current system state. */ EXTERN System_state_Codes _System_state_Current; /* + * _System_state_Handler_initialization + * + * DESCRIPTION: + * + * This routine initializes the system state handler. + */ + +STATIC INLINE void _System_state_Handler_initialization ( + boolean is_multiprocessing +); + +/* * _System_state_Set * * DESCRIPTION: diff --git a/c/src/exec/score/include/rtems/score/thread.h b/c/src/exec/score/include/rtems/score/thread.h index 37a5898d01..823a4e6760 100644 --- a/c/src/exec/score/include/rtems/score/thread.h +++ b/c/src/exec/score/include/rtems/score/thread.h @@ -14,77 +14,44 @@ * $Id$ */ -#ifndef __RTEMS_THREAD_h -#define __RTEMS_THREAD_h +#ifndef __THREAD_h +#define __THREAD_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/asr.h> -#include <rtems/attr.h> -#include <rtems/context.h> -#include <rtems/cpu.h> -#include <rtems/eventset.h> -#include <rtems/modes.h> -#include <rtems/mppkt.h> -#include <rtems/object.h> -#include <rtems/options.h> -#include <rtems/priority.h> -#include <rtems/stack.h> -#include <rtems/states.h> -#include <rtems/tod.h> -#include <rtems/tqdata.h> -#include <rtems/watchdog.h> - -/* - * Notepads constants (indices into notepad array) - */ - -#define RTEMS_NOTEPAD_FIRST 0 /* lowest numbered notepad */ -#define RTEMS_NOTEPAD_0 0 /* notepad location 0 */ -#define RTEMS_NOTEPAD_1 1 /* notepad location 1 */ -#define RTEMS_NOTEPAD_2 2 /* notepad location 2 */ -#define RTEMS_NOTEPAD_3 3 /* notepad location 3 */ -#define RTEMS_NOTEPAD_4 4 /* notepad location 4 */ -#define RTEMS_NOTEPAD_5 5 /* notepad location 5 */ -#define RTEMS_NOTEPAD_6 6 /* notepad location 6 */ -#define RTEMS_NOTEPAD_7 7 /* notepad location 7 */ -#define RTEMS_NOTEPAD_8 8 /* notepad location 8 */ -#define RTEMS_NOTEPAD_9 9 /* notepad location 9 */ -#define RTEMS_NOTEPAD_10 10 /* notepad location 10 */ -#define RTEMS_NOTEPAD_11 11 /* notepad location 11 */ -#define RTEMS_NOTEPAD_12 12 /* notepad location 12 */ -#define RTEMS_NOTEPAD_13 13 /* notepad location 13 */ -#define RTEMS_NOTEPAD_14 14 /* notepad location 14 */ -#define RTEMS_NOTEPAD_15 15 /* notepad location 15 */ -#define RTEMS_NOTEPAD_LAST RTEMS_NOTEPAD_15 /* highest numbered notepad */ - -#define RTEMS_NUMBER_NOTEPADS (RTEMS_NOTEPAD_LAST+1) - -/* - * The following defines the "return type" of an RTEMS thread. - * - * NOTE: Keep both types for internal threads. - */ - -typedef void rtems_task; -typedef void Thread; +#include <rtems/core/context.h> +#include <rtems/core/cpu.h> +#include <rtems/core/mppkt.h> +#include <rtems/core/object.h> +#include <rtems/core/priority.h> +#include <rtems/core/stack.h> +#include <rtems/core/states.h> +#include <rtems/core/tod.h> +#include <rtems/core/tqdata.h> +#include <rtems/core/watchdog.h> /* - * The following defines the argument to an RTEMS thread. + * The following defines the "return type" of a thread. */ -typedef unsigned32 rtems_task_argument; -typedef unsigned32 Thread_Argument; +typedef void Thread; /* - * The following defines the type for the entry point of an RTEMS thread. + * The following defines the ways in which the entry point for a + * thread can be invoked. Basically, it can be passed any + * combination/permutation of a pointer and an unsigned32 value. + * + * NOTE: For now, we are ignoring the return type. */ -typedef rtems_task ( *rtems_task_entry )( - rtems_task_argument - ); +typedef enum { + THREAD_START_NUMERIC, + THREAD_START_POINTER, + THREAD_START_BOTH_POINTER_FIRST, + THREAD_START_BOTH_NUMERIC_FIRST +} Thread_Start_types; typedef Thread ( *Thread_Entry )( ); @@ -93,19 +60,15 @@ typedef Thread ( *Thread_Entry )( ); * the starting state of a thread. */ -typedef enum { - THREAD_START_NUMERIC, - THREAD_START_POINTER, - THREAD_START_BOTH_POINTER_FIRST, - THREAD_START_BOTH_NUMERIC_FIRST -} Thread_Start_types; - typedef struct { Thread_Entry entry_point; /* starting thread address */ Thread_Start_types prototype; /* how task is invoked */ void *pointer_argument; /* pointer argument */ unsigned32 numeric_argument; /* numeric argument */ - Modes_Control initial_modes; /* initial mode */ + /* initial execution modes */ + boolean is_preemptible; + boolean is_timeslice; + unsigned32 isr_level; Priority_Control initial_priority; /* initial priority */ Stack_Control Initial_stack; /* stack information */ void *fp_context; /* initial FP context area address */ @@ -117,16 +80,21 @@ typedef struct { * a thread which it is waiting for a resource. */ +#define THREAD_STATUS_PROXY_BLOCKING 0x1111111 + typedef struct { Objects_Id id; /* waiting on this object */ - rtems_option option_set; /* wait mode */ - union { - unsigned32 segment_size; /* size of segment requested */ - rtems_event_set event_condition; - unsigned32 *message_size_p; /* ptr for return size of message */ - } Extra; - void *return_argument; /* address of user return param */ - rtems_status_code return_code; /* status for thread awakened */ + unsigned32 count; /* "generic" fields to be used */ + void *return_argument; /* when blocking */ + void *return_argument_1; + unsigned32 option; + + /* + * NOTE: The following assumes that all API return codes can be + * treated as an unsigned32. + */ + unsigned32 return_code; /* status for thread awakened */ + Chain_Control Block2n; /* 2 - n priority blocked chain */ Thread_queue_Control *queue; /* pointer to thread queue */ } Thread_Wait_information; @@ -147,7 +115,7 @@ typedef struct { unsigned32 resource_count; Thread_Wait_information Wait; Watchdog_Control Timer; - rtems_packet_prefix *receive_packet; + MP_packet_Prefix *receive_packet; /****************** end of common block ********************/ Chain_Node Active; } Thread_Proxy_control; @@ -161,15 +129,12 @@ typedef struct { * memory images for the shared part. */ -/* XXX structure in wrong file .. API .. not core */ +typedef enum { + THREAD_API_RTEMS +} Thread_APIs; -typedef struct { - boolean is_global; - unsigned32 Notepads[ RTEMS_NUMBER_NOTEPADS ]; - rtems_event_set pending_events; - rtems_event_set events_out; - ASR_Information Signal; -} RTEMS_API_Control; +#define THREAD_API_FIRST THREAD_API_RTEMS +#define THREAD_API_LAST THREAD_API_RTEMS typedef struct { Objects_Control Object; @@ -179,24 +144,30 @@ typedef struct { unsigned32 resource_count; Thread_Wait_information Wait; Watchdog_Control Timer; - rtems_packet_prefix *receive_packet; + MP_packet_Prefix *receive_packet; /****************** end of common block ********************/ + boolean is_global; Chain_Control *ready; Priority_Information Priority_map; Thread_Start_information Start; - Modes_Control current_modes; + boolean is_preemptible; + boolean is_timeslice; Context_Control Registers; void *fp_context; - RTEMS_API_Control *RTEMS_API; - void *extension; + void *API_Extensions[ THREAD_API_LAST + 1 ]; + void **extensions; } Thread_Control; /* - * External API name for Thread_Control + * The following context area contains the context of the "thread" + * which invoked the start multitasking routine. This context is + * restored as the last action of the stop multitasking routine. Thus + * control of the processor can be returned to the environment + * which initiated the system. */ - -typedef Thread_Control rtems_tcb; - + +EXTERN Context_Control _Thread_BSP_context; + /* * The following declares the dispatch critical section nesting * counter which is used to prevent context switches at inopportune @@ -206,6 +177,14 @@ typedef Thread_Control rtems_tcb; EXTERN unsigned32 _Thread_Dispatch_disable_level; /* + * The following holds how many user extensions are in the system. This + * is used to determine how many user extension data areas to allocate + * per thread. + */ + +EXTERN unsigned32 _Thread_Maximum_extensions; + +/* * The following data items are used to manage timeslicing. */ @@ -228,7 +207,7 @@ EXTERN Thread_Control *_Thread_Executing; /* * The following points to the highest priority ready thread - * in the system. Unless the current thread is RTEMS_NO_PREEMPT, + * in the system. Unless the current thread is not preemptibl, * then this thread will be context switched to when the next * dispatch occurs. */ @@ -243,16 +222,6 @@ EXTERN Thread_Control *_Thread_Heir; EXTERN Thread_Control *_Thread_Allocated_fp; /* - * The following context area contains the context of the "thread" - * which invoked rtems_initialize_executive. This context is restored - * as the last action of the rtems_shutdown_executive directive. Thus - * control of the processor can be returned to the environment - * which initiated RTEMS. - */ - -EXTERN Context_Control _Thread_BSP_context; - -/* * _Thread_Handler_initialization * * DESCRIPTION: @@ -261,8 +230,9 @@ EXTERN Context_Control _Thread_BSP_context; */ void _Thread_Handler_initialization ( - unsigned32 ticks_per_timeslice, - unsigned32 maximum_proxies + unsigned32 ticks_per_timeslice, + unsigned32 maximum_extensions, + unsigned32 maximum_proxies ); /* @@ -272,7 +242,7 @@ void _Thread_Handler_initialization ( * * This routine initiates multitasking. It is invoked only as * part of initialization and its invocation is the last act of - * the rtems_initialize_executive directive. + * the non-multitasking part of the system initialization. */ void _Thread_Start_multitasking ( @@ -286,8 +256,8 @@ void _Thread_Start_multitasking ( * DESCRIPTION: * * This routine halts multitasking and returns control to - * the "thread" which initially invoked the rtems_initialize_executive - * directive. + * the "thread" (i.e. the BSP) which initially invoked the + * routine which initialized the system. */ STATIC INLINE void _Thread_Stop_multitasking( void ); @@ -333,7 +303,9 @@ boolean _Thread_Initialize( unsigned32 stack_size, /* insure it is >= min */ boolean is_fp, /* TRUE if thread uses FP */ Priority_Control priority, - Modes_Control mode, + boolean is_preemptible, + boolean is_timeslice, + unsigned32 isr_level, Objects_Name name ); @@ -452,7 +424,7 @@ void _Thread_Set_transient( * at the priority of the currently executing thread, then the * executing thread's timeslice is reset. Otherwise, the * currently executing thread is placed at the rear of the - * RTEMS_FIFO for this priority and a new heir is selected. + * FIFO for this priority and a new heir is selected. */ void _Thread_Reset_timeslice( void ); @@ -551,8 +523,7 @@ void _Thread_Handler( void ); * DESCRIPTION: * * This routine is invoked when a thread must be unblocked at the - * end of a delay such as the rtems_task_wake_after and rtems_task_wake_when - * directives. + * end of a time based delay (i.e. wake after or wake when). */ void _Thread_Delay_ended( @@ -590,23 +561,14 @@ void _Thread_Set_priority( ); /* - * _Thread_Change_mode + * _Thread_Evaluate_mode * * DESCRIPTION: * - * This routine changes the current values of the modes - * indicated by mask of the calling thread are changed to that - * indicated in mode_set. The former mode of the thread is - * returned in mode_set. If the changes in the current mode - * indicate that a thread dispatch operation may be necessary, - * then need_dispatch is TRUE, otherwise it is FALSE. + * This routine XXX */ -boolean _Thread_Change_mode( - Modes_Control new_mode_set, - Modes_Control mask, - Modes_Control *old_mode_set -); +boolean _Thread_Evaluate_mode( void ); /* * _Thread_Resume @@ -782,8 +744,21 @@ STATIC INLINE Thread_Control *_Thread_Get ( Objects_Locations *location ); -#include <rtems/thread.inl> -#include <rtems/threadmp.h> +/* + * _Thread_Is_proxy_blocking + * + * DESCRIPTION: + * + * This function returns TRUE if the status code is equal to the + * status which indicates that a proxy is blocking, and FALSE otherwise. + */ + +STATIC INLINE boolean _Thread_Is_proxy_blocking ( + unsigned32 code +); + +#include <rtems/core/thread.inl> +#include <rtems/core/threadmp.h> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/threadmp.h b/c/src/exec/score/include/rtems/score/threadmp.h index db94a65d78..89b8e3d597 100644 --- a/c/src/exec/score/include/rtems/score/threadmp.h +++ b/c/src/exec/score/include/rtems/score/threadmp.h @@ -104,7 +104,7 @@ EXTERN Thread_Control *_Thread_MP_Receive; EXTERN Chain_Control _Thread_MP_Active_proxies; EXTERN Chain_Control _Thread_MP_Inactive_proxies; -#include <rtems/threadmp.inl> +#include <rtems/core/threadmp.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/threadq.h b/c/src/exec/score/include/rtems/score/threadq.h index 27a36ab63e..a9fb29bb57 100644 --- a/c/src/exec/score/include/rtems/score/threadq.h +++ b/c/src/exec/score/include/rtems/score/threadq.h @@ -14,18 +14,18 @@ * $Id$ */ -#ifndef __RTEMS_THREAD_QUEUE_h -#define __RTEMS_THREAD_QUEUE_h +#ifndef __THREAD_QUEUE_h +#define __THREAD_QUEUE_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/tqdata.h> +#include <rtems/core/tqdata.h> -#include <rtems/object.h> -#include <rtems/thread.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/thread.h> +#include <rtems/core/watchdog.h> /* * The following type defines the callout used when a remote task @@ -75,7 +75,7 @@ Thread_Control *_Thread_queue_Dequeue( void _Thread_queue_Enqueue( Thread_queue_Control *the_thread_queue, - rtems_interval timeout + Watchdog_Interval timeout ); /* @@ -131,7 +131,8 @@ Thread_Control *_Thread_queue_First( void _Thread_queue_Flush( Thread_queue_Control *the_thread_queue, - Thread_queue_Flush_callout remote_extract_callout + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status ); /* @@ -149,7 +150,8 @@ void _Thread_queue_Initialize( Objects_Classes the_class, Thread_queue_Disciplines the_discipline, States_Control state, - Thread_queue_Extract_callout proxy_extract_callout + Thread_queue_Extract_callout proxy_extract_callout, + unsigned32 timeout_status ); /* @@ -179,7 +181,7 @@ Thread_Control *_Thread_queue_Dequeue_priority( void _Thread_queue_Enqueue_priority( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, - rtems_interval timeout + Watchdog_Interval timeout ); /* @@ -231,13 +233,13 @@ Thread_Control *_Thread_queue_Dequeue_fifo( * * This routine enqueues the currently executing thread on * the_thread_queue with an optional timeout using the - * RTEMS_FIFO discipline. + * FIFO discipline. */ void _Thread_queue_Enqueue_fifo( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, - rtems_interval timeout + Watchdog_Interval timeout ); /* diff --git a/c/src/exec/score/include/rtems/score/tod.h b/c/src/exec/score/include/rtems/score/tod.h index ae7e2b9747..6c2882a3c5 100644 --- a/c/src/exec/score/include/rtems/score/tod.h +++ b/c/src/exec/score/include/rtems/score/tod.h @@ -14,15 +14,15 @@ * $Id$ */ -#ifndef __RTEMS_TIME_OF_DAY_h -#define __RTEMS_TIME_OF_DAY_h +#ifndef __TIME_OF_DAY_h +#define __TIME_OF_DAY_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/object.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/watchdog.h> /* * The following constants are related to the time of day. @@ -42,7 +42,7 @@ extern "C" { /* * The following constant define the earliest year to which an - * RTEMS time of day can be initialized. This is considered the + * time of day can be initialized. This is considered the * epoch. */ @@ -61,27 +61,27 @@ typedef struct { /* RTEID style time/date */ unsigned32 minute; /* minute, 0 -> 59 */ unsigned32 second; /* second, 0 -> 59 */ unsigned32 ticks; /* elapsed ticks between secs */ -} rtems_time_of_day; +} TOD_Control; /* * The following contains the current time of day. */ -EXTERN rtems_time_of_day _TOD_Current; +EXTERN TOD_Control _TOD_Current; /* * The following contains the number of seconds from 00:00:00 * January 1, TOD_BASE_YEAR until the current time of day. */ -EXTERN rtems_interval _TOD_Seconds_since_epoch; +EXTERN Watchdog_Interval _TOD_Seconds_since_epoch; /* * The following contains the number of ticks since the * system was booted. */ -EXTERN rtems_interval _TOD_Ticks_since_boot; +EXTERN Watchdog_Interval _TOD_Ticks_since_boot; /* * The following contains the number of microseconds per tick. @@ -173,8 +173,8 @@ void _TOD_Handler_initialization( */ void _TOD_Set( - rtems_time_of_day *the_tod, - rtems_interval seconds_since_epoch + TOD_Control *the_tod, + Watchdog_Interval seconds_since_epoch ); /* @@ -182,12 +182,12 @@ void _TOD_Set( * * DESCRIPTION: * - * This function returns STATUS.RTEMS_SUCCESSFUL if THE_TOD contains + * This function returns TRUE if THE_TOD contains * a valid time of day, and FALSE otherwise. */ -rtems_status_code _TOD_Validate( - rtems_time_of_day *the_tod +boolean _TOD_Validate( + TOD_Control *the_tod ); /* @@ -198,8 +198,8 @@ rtems_status_code _TOD_Validate( * This function returns the number seconds between the epoch and THE_TOD. */ -rtems_interval _TOD_To_seconds( - rtems_time_of_day *the_tod +Watchdog_Interval _TOD_To_seconds( + TOD_Control *the_tod ); /* @@ -243,7 +243,7 @@ STATIC INLINE void _TOD_Deactivate( void ); */ STATIC INLINE void _TOD_Activate( - rtems_interval ticks + Watchdog_Interval ticks ); /* @@ -262,7 +262,7 @@ void _TOD_Tickle( ); /* - * RTEMS_MILLISECONDS_TO_MICROSECONDS + * TOD_MILLISECONDS_TO_MICROSECONDS * * DESCRIPTION: * @@ -273,10 +273,10 @@ void _TOD_Tickle( * This must be a macro so it can be used in "static" tables. */ -#define RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000) +#define TOD_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000) /* - * RTEMS_MILLISECONDS_TO_TICKS + * TOD_MILLISECONDS_TO_TICKS * * DESCRIPTION: * @@ -287,10 +287,10 @@ void _TOD_Tickle( * This must be a macro so it can be used in "static" tables. */ -#define RTEMS_MILLISECONDS_TO_TICKS(_ms) \ - (RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick) +#define TOD_MILLISECONDS_TO_TICKS(_ms) \ + (TOD_MILLISECONDS_TO_MICROSECONDS(_ms) / _TOD_Microseconds_per_tick) -#include <rtems/tod.inl> +#include <rtems/core/tod.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/tqdata.h b/c/src/exec/score/include/rtems/score/tqdata.h index f962f409d2..128c4183a3 100644 --- a/c/src/exec/score/include/rtems/score/tqdata.h +++ b/c/src/exec/score/include/rtems/score/tqdata.h @@ -14,16 +14,16 @@ * $Id$ */ -#ifndef __RTEMS_THREAD_QUEUE_DATA_h -#define __RTEMS_THREAD_QUEUE_DATA_h +#ifndef __THREAD_QUEUE_DATA_h +#define __THREAD_QUEUE_DATA_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/chain.h> -#include <rtems/priority.h> -#include <rtems/states.h> +#include <rtems/core/chain.h> +#include <rtems/core/priority.h> +#include <rtems/core/states.h> /* * The following enumerated type details all of the disciplines @@ -31,8 +31,8 @@ extern "C" { */ typedef enum { - THREAD_QUEUE_DISCIPLINE_FIFO, /* RTEMS_FIFO queue discipline */ - THREAD_QUEUE_DISCIPLINE_PRIORITY /* RTEMS_PRIORITY queue discipline */ + THREAD_QUEUE_DISCIPLINE_FIFO, /* FIFO queue discipline */ + THREAD_QUEUE_DISCIPLINE_PRIORITY /* PRIORITY queue discipline */ } Thread_queue_Disciplines; /* @@ -51,6 +51,7 @@ typedef struct { boolean sync; /* alloc/dealloc critical section */ Thread_queue_Disciplines discipline; /* queue discipline */ States_Control state; /* state of threads on Thread_q */ + unsigned32 timeout_status; } Thread_queue_Control; /* @@ -80,7 +81,7 @@ STATIC INLINE boolean _Thread_queue_Is_reverse_search ( Priority_Control the_priority ); -#include <rtems/tqdata.inl> +#include <rtems/core/tqdata.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/userext.h b/c/src/exec/score/include/rtems/score/userext.h index 56fae9b7db..2808b3566e 100644 --- a/c/src/exec/score/include/rtems/score/userext.h +++ b/c/src/exec/score/include/rtems/score/userext.h @@ -2,7 +2,7 @@ * * This include file contains all information about user extensions. This * Handler provides mechanisms which can be used to initialize and manipulate - * all RTEMS user extensions. + * all user extensions. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,23 +15,89 @@ * $Id$ */ -#ifndef __RTEMS_USER_EXTENSIONS_h -#define __RTEMS_USER_EXTENSIONS_h +#ifndef __USER_EXTENSIONS_h +#define __USER_EXTENSIONS_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/config.h> -#include <rtems/thread.h> +#include <rtems/core/interr.h> +#include <rtems/core/chain.h> +#include <rtems/core/thread.h> + +/* + * The following records defines the User Extension Table. + * This table defines the application dependent routines which + * are invoked at critical points in the life of each thread and + * the system as a whole. + */ + +typedef void User_extensions_routine; + +typedef boolean ( *User_extensions_thread_create_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_delete_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_start_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_restart_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_switch_extension )( + Thread_Control *, + Thread_Control * + ); + +typedef User_extensions_routine (*User_extensions_thread_post_switch_extension)( + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_begin_extension )( + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_thread_exitted_extension )( + Thread_Control * + ); + +typedef User_extensions_routine ( *User_extensions_fatal_extension )( + Internal_errors_Source /* the_source */, + boolean /* is_internal */, + unsigned32 /* the_error */ + ); + + +typedef struct { + User_extensions_thread_create_extension thread_create; + User_extensions_thread_start_extension thread_start; + User_extensions_thread_restart_extension thread_restart; + User_extensions_thread_delete_extension thread_delete; + User_extensions_thread_switch_extension thread_switch; + User_extensions_thread_post_switch_extension thread_post_switch; + User_extensions_thread_begin_extension thread_begin; + User_extensions_thread_exitted_extension thread_exitted; + User_extensions_fatal_extension fatal; +} User_extensions_Table; /* * The following is used to manage each user extension set. */ typedef struct { - Chain_Node Node; - rtems_extensions_table Callouts; + Chain_Node Node; + User_extensions_Table Callouts; } User_extensions_Control; /* @@ -57,7 +123,7 @@ EXTERN Chain_Control _User_extensions_List; */ STATIC INLINE void _User_extensions_Handler_initialization ( - rtems_extensions_table *initial_extensions + User_extensions_Table *initial_extensions ); /* @@ -70,7 +136,19 @@ STATIC INLINE void _User_extensions_Handler_initialization ( STATIC INLINE void _User_extensions_Add_set ( User_extensions_Control *the_extension, - rtems_extensions_table *extension_table + User_extensions_Table *extension_table +); + +/* + * _User_extensions_Add_API_set + * + * DESCRIPTION: + * + * This routine is used to add an API extension set to the active list. + */ + +STATIC INLINE void _User_extensions_Add_API_set ( + User_extensions_Control *the_extension ); /* @@ -86,59 +164,59 @@ STATIC INLINE void _User_extensions_Remove_set ( ); /* - * _User_extensions_Task_create + * _User_extensions_Thread_create * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_create directive. + * the thread creation operate. */ -STATIC INLINE void _User_extensions_Task_create ( +boolean _User_extensions_Thread_create ( Thread_Control *the_thread ); /* - * _User_extensions_Task_delete + * _User_extensions_Thread_delete * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_delete directive. + * the thread deletion operation. */ -STATIC INLINE void _User_extensions_Task_delete ( +void _User_extensions_Thread_delete ( Thread_Control *the_thread ); /* - * _User_extensions_Task_start + * _User_extensions_Thread_start * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_start directive. + * the thread start operation. */ -STATIC INLINE void _User_extensions_Task_start ( +void _User_extensions_Thread_start ( Thread_Control *the_thread ); /* - * _User_extensions_Task_restart + * _User_extensions_Thread_restart * * DESCRIPTION: * * This routine is used to invoke the user extension for - * the rtems_task_restart directive. + * the thread restart operation. */ -STATIC INLINE void _User_extensions_Task_restart ( +void _User_extensions_Thread_restart ( Thread_Control *the_thread ); /* - * _User_extensions_Task_switch + * _User_extensions_Thread_switch * * DESCRIPTION: * @@ -146,47 +224,49 @@ STATIC INLINE void _User_extensions_Task_restart ( * is invoked when a context switch occurs. */ -STATIC INLINE void _User_extensions_Task_switch ( +STATIC INLINE void _User_extensions_Thread_switch ( Thread_Control *executing, Thread_Control *heir ); /* - * _User_extensions_Task_begin + * _User_extensions_Thread_post_switch * * DESCRIPTION: * - * This routine is used to invoke the user extension which - * is invoked when a task begins. + * This routine is used to invoke the user extension which is invoked + * after a context switch occurs (i.e. we are running in the context + * of the new thread). */ - -STATIC INLINE void _User_extensions_Task_begin ( + +STATIC INLINE void _User_extensions_Thread_post_switch ( Thread_Control *executing ); + /* - * _User_extensions_Task_exitted + * _User_extensions_Thread_begin * * DESCRIPTION: * * This routine is used to invoke the user extension which - * is invoked when a task exits. + * is invoked when a thread begins. */ -STATIC INLINE void _User_extensions_Task_exitted ( +void _User_extensions_Thread_begin ( Thread_Control *executing ); /* - * _User_extensions_Task_exitted + * _User_extensions_Thread_exitted * * DESCRIPTION: * * This routine is used to invoke the user extension which - * is invoked when a task exits. + * is invoked when a thread exits. */ -STATIC INLINE void _User_extensions_Task_exitted ( +void _User_extensions_Thread_exitted ( Thread_Control *executing ); @@ -195,15 +275,17 @@ STATIC INLINE void _User_extensions_Task_exitted ( * * DESCRIPTION: * - * This routine is used to invoke the user extension for - * the rtems_fatal_error_occurred directive. + * This routine is used to invoke the user extension invoked + * when a fatal error occurs. */ -STATIC INLINE void _User_extensions_Fatal ( - unsigned32 the_error +void _User_extensions_Fatal ( + Internal_errors_Source the_source, + boolean is_internal, + unsigned32 the_error ); -#include <rtems/userext.inl> +#include <rtems/core/userext.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/watchdog.h b/c/src/exec/score/include/rtems/score/watchdog.h index 70de7018dd..7e871c8881 100644 --- a/c/src/exec/score/include/rtems/score/watchdog.h +++ b/c/src/exec/score/include/rtems/score/watchdog.h @@ -15,29 +15,29 @@ * $Id$ */ -#ifndef __RTEMS_WATCHDOG_h -#define __RTEMS_WATCHDOG_h +#ifndef __WATCHDOG_h +#define __WATCHDOG_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/object.h> +#include <rtems/core/object.h> /* * The following type defines the control block used to manage * intervals. */ -typedef unsigned32 rtems_interval; +typedef unsigned32 Watchdog_Interval; /* - * The following types define a pointer to a watchdog/timer service routine. + * The following types define a pointer to a watchdog service routine. */ -typedef void rtems_timer_service_routine; +typedef void Watchdog_Service_routine; -typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( +typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )( Objects_Id, void * ); @@ -46,7 +46,7 @@ typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( * Constant for indefinite wait. (actually an illegal interval) */ -#define RTEMS_NO_TIMEOUT 0 +#define WATCHDOG_NO_TIMEOUT 0 /* * The following enumerated type details the modes in which the @@ -92,9 +92,9 @@ typedef enum { typedef struct { Chain_Node Node; Watchdog_States state; - rtems_interval initial; - rtems_interval delta_interval; - rtems_timer_service_routine_entry routine; + Watchdog_Interval initial; + Watchdog_Interval delta_interval; + Watchdog_Service_routine_entry routine; Objects_Id id; void *user_data; } Watchdog_Control; @@ -140,7 +140,7 @@ void _Watchdog_Handler_initialization( void ); STATIC INLINE void _Watchdog_Initialize( Watchdog_Control *the_watchdog, - rtems_timer_service_routine_entry routine, + Watchdog_Service_routine_entry routine, Objects_Id id, void *user_data ); @@ -238,7 +238,7 @@ STATIC INLINE void _Watchdog_Tickle_seconds( void ); STATIC INLINE void _Watchdog_Insert_ticks( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ); @@ -256,7 +256,7 @@ STATIC INLINE void _Watchdog_Insert_ticks( STATIC INLINE void _Watchdog_Insert_seconds( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ); @@ -273,7 +273,7 @@ STATIC INLINE void _Watchdog_Insert_seconds( STATIC INLINE void _Watchdog_Adjust_seconds( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ); /* @@ -288,7 +288,7 @@ STATIC INLINE void _Watchdog_Adjust_seconds( STATIC INLINE void _Watchdog_Adjust_ticks( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ); /* @@ -374,7 +374,7 @@ STATIC INLINE Watchdog_Control *_Watchdog_Last( void _Watchdog_Adjust ( Chain_Control *header, Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ); /* @@ -408,7 +408,7 @@ void _Watchdog_Tickle ( Chain_Control *header ); -#include <rtems/watchdog.inl> +#include <rtems/core/watchdog.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/score/wkspace.h b/c/src/exec/score/include/rtems/score/wkspace.h index 7050be6953..a262761d68 100644 --- a/c/src/exec/score/include/rtems/score/wkspace.h +++ b/c/src/exec/score/include/rtems/score/wkspace.h @@ -1,8 +1,8 @@ /* wkspace.h * - * This include file contains information related to the RTEMS + * This include file contains information related to the * RAM Workspace. This Handler provides mechanisms which can be used to - * define, initialize and manipulate the RTEMS workspace. + * define, initialize and manipulate the workspace. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -15,19 +15,18 @@ * $Id$ */ -#ifndef __RTEMS_WORKSPACE_h -#define __RTEMS_WORKSPACE_h +#ifndef __WORKSPACE_h +#define __WORKSPACE_h #ifdef __cplusplus extern "C" { #endif -#include <rtems/heap.h> -#include <rtems/fatal.h> -#include <rtems/status.h> +#include <rtems/core/heap.h> +#include <rtems/core/interr.h> /* - * The following is used to manage the RTEMS Workspace. + * The following is used to manage the Workspace. * */ @@ -67,8 +66,7 @@ STATIC INLINE void *_Workspace_Allocate( * * This routine returns the address of a block of memory of size * bytes. If a block of the appropriate size cannot be allocated - * from the workspace, then the rtems_fatal_error_occurred directive - * is invoked. + * from the workspace, then the internal error handler is invoked. */ void *_Workspace_Allocate_or_fatal_error( @@ -89,7 +87,7 @@ STATIC INLINE boolean _Workspace_Free( void *block ); -#include <rtems/wkspace.inl> +#include <rtems/core/wkspace.inl> #ifdef __cplusplus } diff --git a/c/src/exec/score/include/rtems/system.h b/c/src/exec/score/include/rtems/system.h index 5f627c1a7c..037fe93e66 100644 --- a/c/src/exec/score/include/rtems/system.h +++ b/c/src/exec/score/include/rtems/system.h @@ -76,9 +76,7 @@ extern "C" { typedef void * proc_ptr; -#include <rtems/cpu.h> /* processor specific information */ -#include <rtems/status.h> /* RTEMS status codes */ -#include <rtems/directives.h> +#include <rtems/core/cpu.h> /* processor specific information */ /* * Define NULL @@ -116,12 +114,6 @@ extern const char _RTEMS_version[]; /* RTEMS version string */ extern const char _Copyright_Notice[]; /* RTEMS copyright string */ /* - * The jump table of entry points into RTEMS directives. - */ - -extern const void * _Entry_points[ RTEMS_NUMBER_OF_ENTRY_POINTS ]; - -/* * The following defines the CPU dependent information table. */ diff --git a/c/src/exec/score/inline/address.inl b/c/src/exec/score/inline/address.inl index f9189e625e..dd2a789b1e 100644 --- a/c/src/exec/score/inline/address.inl +++ b/c/src/exec/score/inline/address.inl @@ -28,7 +28,7 @@ STATIC INLINE void *_Addresses_Add_offset ( unsigned32 offset ) { - return (base + offset); + return (void *)((char *)base + offset); } /*PAGE @@ -42,23 +42,7 @@ STATIC INLINE void *_Addresses_Subtract_offset ( unsigned32 offset ) { - return (base - offset); -} - -/*PAGE - * - * _Addresses_Add - * - * NOTE: The cast of an address to an unsigned32 makes this code - * dependent on an addresses being thirty two bits. - */ - -STATIC INLINE void *_Addresses_Add ( - void *left, - void *right -) -{ - return (left + (unsigned32)right); + return (void *)((char *)base - offset); } /*PAGE diff --git a/c/src/exec/score/inline/coremutex.inl b/c/src/exec/score/inline/coremutex.inl new file mode 100644 index 0000000000..8681795085 --- /dev/null +++ b/c/src/exec/score/inline/coremutex.inl @@ -0,0 +1,104 @@ +/* inline/coremutex.inl + * + * This include file contains all of the inlined routines associated + * with the CORE mutexes. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __INLINE_CORE_MUTEX_inl +#define __INLINE_CORE_MUTEX_inl + +/*PAGE + * + * _CORE_mutex_Is_locked + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_locked( + CORE_mutex_Control *the_mutex +) +{ + return the_mutex->lock == CORE_MUTEX_LOCKED; +} + +/*PAGE + * + * _CORE_mutex_Is_fifo + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_fifo( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_FIFO; +} + +/*PAGE + * + * _CORE_mutex_Is_priority + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY; +} + +/*PAGE + * + * _CORE_mutex_Is_inherit_priority + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_inherit_priority( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; +} + +/*PAGE + * + * _CORE_mutex_Is_priority_ceiling + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority_ceiling( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; +} + +/*PAGE + * + * _CORE_mutex_Is_nesting_allowed + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex allows a task to obtain a + * semaphore more than once and nest. + */ + +STATIC INLINE boolean _CORE_mutex_Is_nesting_allowed( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->allow_nesting == TRUE; + +} + +#endif +/* end of include file */ diff --git a/c/src/exec/score/inline/coresem.inl b/c/src/exec/score/inline/coresem.inl new file mode 100644 index 0000000000..53f7d68595 --- /dev/null +++ b/c/src/exec/score/inline/coresem.inl @@ -0,0 +1,47 @@ +/* inline/coresem.inl + * + * This include file contains all of the inlined routines associated + * with the CORE semaphore. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __INLINE_CORE_SEMAPHORE_inl +#define __INLINE_CORE_SEMAPHORE_inl + +/*PAGE + * + * _CORE_semaphore_Is_priority + * + */ + +STATIC INLINE boolean _CORE_semaphore_Is_priority( + CORE_semaphore_Attributes *the_attribute +) +{ + return ( the_attribute->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ); +} + +/*PAGE + * + * _CORE_semaphore_Get_count + * + */ + +STATIC INLINE unsigned32 _CORE_semaphore_Get_count( + CORE_semaphore_Control *the_semaphore +) +{ + return the_semaphore->count; +} + +#endif +/* end of include file */ diff --git a/c/src/exec/score/inline/heap.inl b/c/src/exec/score/inline/heap.inl index 58be9b02af..c28f1a6067 100644 --- a/c/src/exec/score/inline/heap.inl +++ b/c/src/exec/score/inline/heap.inl @@ -17,7 +17,7 @@ #ifndef __HEAP_inl #define __HEAP_inl -#include <rtems/address.h> +#include <rtems/core/address.h> /*PAGE * diff --git a/c/src/exec/score/inline/isr.inl b/c/src/exec/score/inline/isr.inl index f44880c3b6..222fcadb17 100644 --- a/c/src/exec/score/inline/isr.inl +++ b/c/src/exec/score/inline/isr.inl @@ -19,18 +19,6 @@ /*PAGE * - * _ISR_Handler_initialization - * - */ - -STATIC INLINE void _ISR_Handler_initialization ( void ) -{ - _ISR_Signals_to_thread_executing = FALSE; - _ISR_Nest_level = 0; -} - -/*PAGE - * * _ISR_Is_in_progress * */ diff --git a/c/src/exec/score/inline/mppkt.inl b/c/src/exec/score/inline/mppkt.inl index 22ec30a28c..c23d756ec9 100644 --- a/c/src/exec/score/inline/mppkt.inl +++ b/c/src/exec/score/inline/mppkt.inl @@ -26,7 +26,7 @@ */ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( - rtems_mp_packet_classes the_packet_class + MP_packet_Classes the_packet_class ) { return ( the_packet_class <= MP_PACKET_CLASSES_LAST ); @@ -39,7 +39,7 @@ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( */ STATIC INLINE boolean _Mp_packet_Is_null ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ) { return the_packet == NULL; diff --git a/c/src/exec/score/inline/object.inl b/c/src/exec/score/inline/object.inl index b6ae73a351..eb07a24890 100644 --- a/c/src/exec/score/inline/object.inl +++ b/c/src/exec/score/inline/object.inl @@ -36,10 +36,10 @@ STATIC INLINE Objects_Id _Objects_Build_id( /*PAGE * - * rtems_get_class + * _Objects_Get_class */ -STATIC INLINE Objects_Classes rtems_get_class( +STATIC INLINE Objects_Classes _Objects_Get_class( Objects_Id id ) { @@ -50,11 +50,11 @@ STATIC INLINE Objects_Classes rtems_get_class( /*PAGE * - * rtems_get_node + * _Objects_Get_node * */ -STATIC INLINE unsigned32 rtems_get_node( +STATIC INLINE unsigned32 _Objects_Get_node( Objects_Id id ) { @@ -63,11 +63,11 @@ STATIC INLINE unsigned32 rtems_get_node( /*PAGE * - * rtems_get_index + * _Objects_Get_index * */ -STATIC INLINE unsigned32 rtems_get_index( +STATIC INLINE unsigned32 _Objects_Get_index( Objects_Id id ) { @@ -110,7 +110,7 @@ STATIC INLINE boolean _Objects_Is_local_id( Objects_Id id ) { - return _Objects_Is_local_node( rtems_get_node(id) ); + return _Objects_Is_local_node( _Objects_Get_node(id) ); } /*PAGE @@ -168,7 +168,7 @@ STATIC INLINE void _Objects_Open( { unsigned32 index; - index = rtems_get_index( the_object->id ); + index = _Objects_Get_index( the_object->id ); information->local_table[ index ] = the_object; if ( information->is_string ) @@ -190,7 +190,7 @@ STATIC INLINE void _Objects_Close( { unsigned32 index; - index = rtems_get_index( the_object->id ); + index = _Objects_Get_index( the_object->id ); information->local_table[ index ] = NULL; _Objects_Clear_name( the_object->name, information->name_length ); } diff --git a/c/src/exec/score/inline/priority.inl b/c/src/exec/score/inline/priority.inl index b2bc8535ff..0ecd3c64a4 100644 --- a/c/src/exec/score/inline/priority.inl +++ b/c/src/exec/score/inline/priority.inl @@ -17,7 +17,7 @@ #ifndef __PRIORITY_inl #define __PRIORITY_inl -#include <rtems/bitfield.h> +#include <rtems/core/bitfield.h> /*PAGE * @@ -44,8 +44,12 @@ STATIC INLINE boolean _Priority_Is_valid ( Priority_Control the_priority ) { - return ( ( the_priority >= RTEMS_MINIMUM_PRIORITY ) && - ( the_priority <= RTEMS_MAXIMUM_PRIORITY ) ); + /* + * Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned, + * then checking for less than 0 is unnecessary. + */ + + return ( the_priority <= PRIORITY_MAXIMUM ); } /*PAGE diff --git a/c/src/exec/score/inline/rtems/score/address.inl b/c/src/exec/score/inline/rtems/score/address.inl index f9189e625e..dd2a789b1e 100644 --- a/c/src/exec/score/inline/rtems/score/address.inl +++ b/c/src/exec/score/inline/rtems/score/address.inl @@ -28,7 +28,7 @@ STATIC INLINE void *_Addresses_Add_offset ( unsigned32 offset ) { - return (base + offset); + return (void *)((char *)base + offset); } /*PAGE @@ -42,23 +42,7 @@ STATIC INLINE void *_Addresses_Subtract_offset ( unsigned32 offset ) { - return (base - offset); -} - -/*PAGE - * - * _Addresses_Add - * - * NOTE: The cast of an address to an unsigned32 makes this code - * dependent on an addresses being thirty two bits. - */ - -STATIC INLINE void *_Addresses_Add ( - void *left, - void *right -) -{ - return (left + (unsigned32)right); + return (void *)((char *)base - offset); } /*PAGE diff --git a/c/src/exec/score/inline/rtems/score/coremutex.inl b/c/src/exec/score/inline/rtems/score/coremutex.inl new file mode 100644 index 0000000000..8681795085 --- /dev/null +++ b/c/src/exec/score/inline/rtems/score/coremutex.inl @@ -0,0 +1,104 @@ +/* inline/coremutex.inl + * + * This include file contains all of the inlined routines associated + * with the CORE mutexes. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __INLINE_CORE_MUTEX_inl +#define __INLINE_CORE_MUTEX_inl + +/*PAGE + * + * _CORE_mutex_Is_locked + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_locked( + CORE_mutex_Control *the_mutex +) +{ + return the_mutex->lock == CORE_MUTEX_LOCKED; +} + +/*PAGE + * + * _CORE_mutex_Is_fifo + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_fifo( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_FIFO; +} + +/*PAGE + * + * _CORE_mutex_Is_priority + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY; +} + +/*PAGE + * + * _CORE_mutex_Is_inherit_priority + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_inherit_priority( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; +} + +/*PAGE + * + * _CORE_mutex_Is_priority_ceiling + * + */ + +STATIC INLINE boolean _CORE_mutex_Is_priority_ceiling( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; +} + +/*PAGE + * + * _CORE_mutex_Is_nesting_allowed + * + * DESCRIPTION: + * + * This routine returns TRUE if the mutex allows a task to obtain a + * semaphore more than once and nest. + */ + +STATIC INLINE boolean _CORE_mutex_Is_nesting_allowed( + CORE_mutex_Attributes *the_attribute +) +{ + return the_attribute->allow_nesting == TRUE; + +} + +#endif +/* end of include file */ diff --git a/c/src/exec/score/inline/rtems/score/coresem.inl b/c/src/exec/score/inline/rtems/score/coresem.inl new file mode 100644 index 0000000000..53f7d68595 --- /dev/null +++ b/c/src/exec/score/inline/rtems/score/coresem.inl @@ -0,0 +1,47 @@ +/* inline/coresem.inl + * + * This include file contains all of the inlined routines associated + * with the CORE semaphore. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __INLINE_CORE_SEMAPHORE_inl +#define __INLINE_CORE_SEMAPHORE_inl + +/*PAGE + * + * _CORE_semaphore_Is_priority + * + */ + +STATIC INLINE boolean _CORE_semaphore_Is_priority( + CORE_semaphore_Attributes *the_attribute +) +{ + return ( the_attribute->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ); +} + +/*PAGE + * + * _CORE_semaphore_Get_count + * + */ + +STATIC INLINE unsigned32 _CORE_semaphore_Get_count( + CORE_semaphore_Control *the_semaphore +) +{ + return the_semaphore->count; +} + +#endif +/* end of include file */ diff --git a/c/src/exec/score/inline/rtems/score/heap.inl b/c/src/exec/score/inline/rtems/score/heap.inl index 58be9b02af..c28f1a6067 100644 --- a/c/src/exec/score/inline/rtems/score/heap.inl +++ b/c/src/exec/score/inline/rtems/score/heap.inl @@ -17,7 +17,7 @@ #ifndef __HEAP_inl #define __HEAP_inl -#include <rtems/address.h> +#include <rtems/core/address.h> /*PAGE * diff --git a/c/src/exec/score/inline/rtems/score/isr.inl b/c/src/exec/score/inline/rtems/score/isr.inl index f44880c3b6..222fcadb17 100644 --- a/c/src/exec/score/inline/rtems/score/isr.inl +++ b/c/src/exec/score/inline/rtems/score/isr.inl @@ -19,18 +19,6 @@ /*PAGE * - * _ISR_Handler_initialization - * - */ - -STATIC INLINE void _ISR_Handler_initialization ( void ) -{ - _ISR_Signals_to_thread_executing = FALSE; - _ISR_Nest_level = 0; -} - -/*PAGE - * * _ISR_Is_in_progress * */ diff --git a/c/src/exec/score/inline/rtems/score/mppkt.inl b/c/src/exec/score/inline/rtems/score/mppkt.inl index 22ec30a28c..c23d756ec9 100644 --- a/c/src/exec/score/inline/rtems/score/mppkt.inl +++ b/c/src/exec/score/inline/rtems/score/mppkt.inl @@ -26,7 +26,7 @@ */ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( - rtems_mp_packet_classes the_packet_class + MP_packet_Classes the_packet_class ) { return ( the_packet_class <= MP_PACKET_CLASSES_LAST ); @@ -39,7 +39,7 @@ STATIC INLINE boolean _Mp_packet_Is_valid_packet_class ( */ STATIC INLINE boolean _Mp_packet_Is_null ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ) { return the_packet == NULL; diff --git a/c/src/exec/score/inline/rtems/score/object.inl b/c/src/exec/score/inline/rtems/score/object.inl index b6ae73a351..eb07a24890 100644 --- a/c/src/exec/score/inline/rtems/score/object.inl +++ b/c/src/exec/score/inline/rtems/score/object.inl @@ -36,10 +36,10 @@ STATIC INLINE Objects_Id _Objects_Build_id( /*PAGE * - * rtems_get_class + * _Objects_Get_class */ -STATIC INLINE Objects_Classes rtems_get_class( +STATIC INLINE Objects_Classes _Objects_Get_class( Objects_Id id ) { @@ -50,11 +50,11 @@ STATIC INLINE Objects_Classes rtems_get_class( /*PAGE * - * rtems_get_node + * _Objects_Get_node * */ -STATIC INLINE unsigned32 rtems_get_node( +STATIC INLINE unsigned32 _Objects_Get_node( Objects_Id id ) { @@ -63,11 +63,11 @@ STATIC INLINE unsigned32 rtems_get_node( /*PAGE * - * rtems_get_index + * _Objects_Get_index * */ -STATIC INLINE unsigned32 rtems_get_index( +STATIC INLINE unsigned32 _Objects_Get_index( Objects_Id id ) { @@ -110,7 +110,7 @@ STATIC INLINE boolean _Objects_Is_local_id( Objects_Id id ) { - return _Objects_Is_local_node( rtems_get_node(id) ); + return _Objects_Is_local_node( _Objects_Get_node(id) ); } /*PAGE @@ -168,7 +168,7 @@ STATIC INLINE void _Objects_Open( { unsigned32 index; - index = rtems_get_index( the_object->id ); + index = _Objects_Get_index( the_object->id ); information->local_table[ index ] = the_object; if ( information->is_string ) @@ -190,7 +190,7 @@ STATIC INLINE void _Objects_Close( { unsigned32 index; - index = rtems_get_index( the_object->id ); + index = _Objects_Get_index( the_object->id ); information->local_table[ index ] = NULL; _Objects_Clear_name( the_object->name, information->name_length ); } diff --git a/c/src/exec/score/inline/rtems/score/priority.inl b/c/src/exec/score/inline/rtems/score/priority.inl index b2bc8535ff..0ecd3c64a4 100644 --- a/c/src/exec/score/inline/rtems/score/priority.inl +++ b/c/src/exec/score/inline/rtems/score/priority.inl @@ -17,7 +17,7 @@ #ifndef __PRIORITY_inl #define __PRIORITY_inl -#include <rtems/bitfield.h> +#include <rtems/core/bitfield.h> /*PAGE * @@ -44,8 +44,12 @@ STATIC INLINE boolean _Priority_Is_valid ( Priority_Control the_priority ) { - return ( ( the_priority >= RTEMS_MINIMUM_PRIORITY ) && - ( the_priority <= RTEMS_MAXIMUM_PRIORITY ) ); + /* + * Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned, + * then checking for less than 0 is unnecessary. + */ + + return ( the_priority <= PRIORITY_MAXIMUM ); } /*PAGE diff --git a/c/src/exec/score/inline/rtems/score/stack.inl b/c/src/exec/score/inline/rtems/score/stack.inl index 24a6d9d873..7c6acf7cb3 100644 --- a/c/src/exec/score/inline/rtems/score/stack.inl +++ b/c/src/exec/score/inline/rtems/score/stack.inl @@ -43,7 +43,7 @@ STATIC INLINE boolean _Stack_Is_enough ( unsigned32 size ) { - return ( size >= RTEMS_MINIMUM_STACK_SIZE ); + return ( size >= STACK_MINIMUM_SIZE ); } /*PAGE diff --git a/c/src/exec/score/inline/rtems/score/states.inl b/c/src/exec/score/inline/rtems/score/states.inl index 316f40e4eb..23ee8cacbc 100644 --- a/c/src/exec/score/inline/rtems/score/states.inl +++ b/c/src/exec/score/inline/rtems/score/states.inl @@ -1,7 +1,7 @@ /* states.inl * * This file contains the macro implementation of the inlined - * routines associated with RTEMS state information. + * routines associated with thread state information. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -177,6 +177,19 @@ STATIC INLINE boolean _States_Is_waiting_for_event ( /*PAGE * + * _States_Is_waiting_for_mutex + * + */ + +STATIC INLINE boolean _States_Is_waiting_for_mutex ( + States_Control the_states +) +{ + return (the_states & STATES_WAITING_FOR_MUTEX); +} + +/*PAGE + * * _States_Is_waiting_for_semaphore * */ diff --git a/c/src/exec/score/inline/rtems/score/sysstate.inl b/c/src/exec/score/inline/rtems/score/sysstate.inl index 14d838cb14..180e6abe54 100644 --- a/c/src/exec/score/inline/rtems/score/sysstate.inl +++ b/c/src/exec/score/inline/rtems/score/sysstate.inl @@ -19,6 +19,19 @@ /*PAGE * + * _System_state_Handler_initialization + */ + +STATIC INLINE void _System_state_Handler_initialization ( + boolean is_multiprocessing +) +{ + _System_state_Current = SYSTEM_STATE_BEFORE_INITIALIZATION; + _System_state_Is_multiprocessing = is_multiprocessing; +} + +/*PAGE + * * _System_state_Set */ diff --git a/c/src/exec/score/inline/rtems/score/thread.inl b/c/src/exec/score/inline/rtems/score/thread.inl index 2a1049f241..e326410112 100644 --- a/c/src/exec/score/inline/rtems/score/thread.inl +++ b/c/src/exec/score/inline/rtems/score/thread.inl @@ -248,7 +248,7 @@ STATIC INLINE Thread_Control *_Thread_Get ( return( _Thread_Executing ); } - the_class = rtems_get_class( id ); + the_class = _Objects_Get_class( id ); if ( the_class > OBJECTS_CLASSES_LAST ) { *location = OBJECTS_ERROR; @@ -265,5 +265,17 @@ STATIC INLINE Thread_Control *_Thread_Get ( return (Thread_Control *) _Objects_Get( information, id, location ); } +/* + * _Thread_Is_proxy_blocking + * + */ + +STATIC INLINE boolean _Thread_Is_proxy_blocking ( + unsigned32 code +) +{ + return (code == THREAD_STATUS_PROXY_BLOCKING); +} + #endif /* end of include file */ diff --git a/c/src/exec/score/inline/rtems/score/tod.inl b/c/src/exec/score/inline/rtems/score/tod.inl index dadcdabcda..d2e26e2f2a 100644 --- a/c/src/exec/score/inline/rtems/score/tod.inl +++ b/c/src/exec/score/inline/rtems/score/tod.inl @@ -58,7 +58,7 @@ STATIC INLINE void _TOD_Deactivate( void ) */ STATIC INLINE void _TOD_Activate( - rtems_interval ticks + Watchdog_Interval ticks ) { _Watchdog_Insert_ticks( diff --git a/c/src/exec/score/inline/rtems/score/userext.inl b/c/src/exec/score/inline/rtems/score/userext.inl index fa5a31c37b..697a7eddd0 100644 --- a/c/src/exec/score/inline/rtems/score/userext.inl +++ b/c/src/exec/score/inline/rtems/score/userext.inl @@ -24,7 +24,7 @@ */ STATIC INLINE void _User_extensions_Handler_initialization ( - rtems_extensions_table *initial_extensions + User_extensions_Table *initial_extensions ) { _Chain_Initialize_empty( &_User_extensions_List ); @@ -42,7 +42,7 @@ STATIC INLINE void _User_extensions_Handler_initialization ( STATIC INLINE void _User_extensions_Add_set ( User_extensions_Control *the_extension, - rtems_extensions_table *extension_table + User_extensions_Table *extension_table ) { the_extension->Callouts = *extension_table; @@ -52,130 +52,35 @@ STATIC INLINE void _User_extensions_Add_set ( /*PAGE * - * _User_extensions_Remove_set - */ - -STATIC INLINE void _User_extensions_Remove_set ( - User_extensions_Control *the_extension -) -{ - _Chain_Extract( &the_extension->Node ); -} - -/*PAGE - * - * _User_extensions_Task_create - * + * _User_extensions_Add_API_set */ - -STATIC INLINE void _User_extensions_Task_create ( - Thread_Control *the_thread + +STATIC INLINE void _User_extensions_Add_API_set ( + User_extensions_Control *the_extension ) { - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.first ; - !_Chain_Is_tail( &_User_extensions_List, the_node ) ; - the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_create != NULL ) - (*the_extension->Callouts.rtems_task_create)( - _Thread_Executing, - the_thread - ); - } + _Chain_Prepend( &_User_extensions_List, &the_extension->Node ); } - + /*PAGE * - * _User_extensions_Task_delete - */ - -STATIC INLINE void _User_extensions_Task_delete ( - Thread_Control *the_thread -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.last ; - !_Chain_Is_head( &_User_extensions_List, the_node ) ; - the_node = the_node->previous ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_delete != NULL ) - (*the_extension->Callouts.rtems_task_delete)( - _Thread_Executing, - the_thread - ); - } -} - -/*PAGE - * - * _User_extensions_Task_start - * - */ - -STATIC INLINE void _User_extensions_Task_start ( - Thread_Control *the_thread -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.first ; - !_Chain_Is_tail( &_User_extensions_List, the_node ) ; - the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_start != NULL ) - (*the_extension->Callouts.rtems_task_start)( - _Thread_Executing, - the_thread - ); - } -} - -/*PAGE - * - * _User_extensions_Task_restart - * + * _User_extensions_Remove_set */ -STATIC INLINE void _User_extensions_Task_restart ( - Thread_Control *the_thread +STATIC INLINE void _User_extensions_Remove_set ( + User_extensions_Control *the_extension ) { - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.first ; - !_Chain_Is_tail( &_User_extensions_List, the_node ) ; - the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_restart != NULL ) - (*the_extension->Callouts.rtems_task_restart)( - _Thread_Executing, - the_thread - ); - } + _Chain_Extract( &the_extension->Node ); } /*PAGE * - * _User_extensions_Task_switch + * _User_extensions_Thread_switch * */ -STATIC INLINE void _User_extensions_Task_switch ( +STATIC INLINE void _User_extensions_Thread_switch ( Thread_Control *executing, Thread_Control *heir ) @@ -189,78 +94,32 @@ STATIC INLINE void _User_extensions_Task_switch ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.task_switch != NULL ) - (*the_extension->Callouts.task_switch)( executing, heir ); + if ( the_extension->Callouts.thread_switch != NULL ) + (*the_extension->Callouts.thread_switch)( executing, heir ); } } /*PAGE * - * _User_extensions_Task_begin + * _User_extensions_Thread_post_switch * */ - -STATIC INLINE void _User_extensions_Task_begin ( + +STATIC INLINE void _User_extensions_Thread_post_switch ( Thread_Control *executing ) { Chain_Node *the_node; User_extensions_Control *the_extension; - + for ( the_node = _User_extensions_List.first ; !_Chain_Is_tail( &_User_extensions_List, the_node ) ; the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.task_begin != NULL ) - (*the_extension->Callouts.task_begin)( executing ); - } -} - -/*PAGE - * - * _User_extensions_Task_exitted - */ - -STATIC INLINE void _User_extensions_Task_exitted ( - Thread_Control *executing -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.last ; - !_Chain_Is_head( &_User_extensions_List, the_node ) ; - the_node = the_node->previous ) { - + the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.task_exitted != NULL ) - (*the_extension->Callouts.task_exitted)( executing ); - } -} - -/*PAGE - * - * _User_extensions_Fatal - */ - -STATIC INLINE void _User_extensions_Fatal ( - unsigned32 the_error -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.last ; - !_Chain_Is_head( &_User_extensions_List, the_node ) ; - the_node = the_node->previous ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.fatal != NULL ) - (*the_extension->Callouts.fatal)( the_error ); + + if ( the_extension->Callouts.thread_post_switch != NULL ) + (*the_extension->Callouts.thread_post_switch)( executing ); } } diff --git a/c/src/exec/score/inline/rtems/score/watchdog.inl b/c/src/exec/score/inline/rtems/score/watchdog.inl index 2e7dca0381..bb7edb82ed 100644 --- a/c/src/exec/score/inline/rtems/score/watchdog.inl +++ b/c/src/exec/score/inline/rtems/score/watchdog.inl @@ -24,10 +24,10 @@ */ STATIC INLINE void _Watchdog_Initialize( - Watchdog_Control *the_watchdog, - rtems_timer_service_routine_entry routine, - Objects_Id id, - void *user_data + Watchdog_Control *the_watchdog, + Watchdog_Service_routine_entry routine, + Objects_Id id, + void *user_data ) { the_watchdog->state = WATCHDOG_INACTIVE; @@ -115,7 +115,7 @@ STATIC INLINE void _Watchdog_Tickle_seconds( void ) STATIC INLINE void _Watchdog_Insert_ticks( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ) { @@ -134,7 +134,7 @@ STATIC INLINE void _Watchdog_Insert_ticks( STATIC INLINE void _Watchdog_Insert_seconds( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ) { @@ -153,7 +153,7 @@ STATIC INLINE void _Watchdog_Insert_seconds( STATIC INLINE void _Watchdog_Adjust_seconds( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ) { @@ -169,7 +169,7 @@ STATIC INLINE void _Watchdog_Adjust_seconds( STATIC INLINE void _Watchdog_Adjust_ticks( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ) { diff --git a/c/src/exec/score/inline/rtems/score/wkspace.inl b/c/src/exec/score/inline/rtems/score/wkspace.inl index 39d5ad8eb8..36ed61d565 100644 --- a/c/src/exec/score/inline/rtems/score/wkspace.inl +++ b/c/src/exec/score/inline/rtems/score/wkspace.inl @@ -1,7 +1,7 @@ /* wkspace.inl * * This include file contains the bodies of the routines which contains - * information related to the RTEMS RAM Workspace. + * information related to the RAM Workspace. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -32,9 +32,12 @@ STATIC INLINE void _Workspace_Handler_initialization( unsigned32 index; unsigned32 memory_available; - if ( (starting_address == NULL) || - !_Addresses_Is_aligned( starting_address ) ) - rtems_fatal_error_occurred( RTEMS_INVALID_ADDRESS ); + if ( !starting_address || !_Addresses_Is_aligned( starting_address ) ) + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS + ); if ( _CPU_Table.do_zero_of_workspace ) { for( zero_out_array = (unsigned32 *) starting_address, index = 0 ; @@ -51,7 +54,11 @@ STATIC INLINE void _Workspace_Handler_initialization( ); if ( memory_available == 0 ) - rtems_fatal_error_occurred( RTEMS_UNSATISFIED ); + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_TOO_LITTLE_WORKSPACE + ); } /*PAGE diff --git a/c/src/exec/score/inline/stack.inl b/c/src/exec/score/inline/stack.inl index 24a6d9d873..7c6acf7cb3 100644 --- a/c/src/exec/score/inline/stack.inl +++ b/c/src/exec/score/inline/stack.inl @@ -43,7 +43,7 @@ STATIC INLINE boolean _Stack_Is_enough ( unsigned32 size ) { - return ( size >= RTEMS_MINIMUM_STACK_SIZE ); + return ( size >= STACK_MINIMUM_SIZE ); } /*PAGE diff --git a/c/src/exec/score/inline/states.inl b/c/src/exec/score/inline/states.inl index 316f40e4eb..23ee8cacbc 100644 --- a/c/src/exec/score/inline/states.inl +++ b/c/src/exec/score/inline/states.inl @@ -1,7 +1,7 @@ /* states.inl * * This file contains the macro implementation of the inlined - * routines associated with RTEMS state information. + * routines associated with thread state information. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -177,6 +177,19 @@ STATIC INLINE boolean _States_Is_waiting_for_event ( /*PAGE * + * _States_Is_waiting_for_mutex + * + */ + +STATIC INLINE boolean _States_Is_waiting_for_mutex ( + States_Control the_states +) +{ + return (the_states & STATES_WAITING_FOR_MUTEX); +} + +/*PAGE + * * _States_Is_waiting_for_semaphore * */ diff --git a/c/src/exec/score/inline/sysstate.inl b/c/src/exec/score/inline/sysstate.inl index 14d838cb14..180e6abe54 100644 --- a/c/src/exec/score/inline/sysstate.inl +++ b/c/src/exec/score/inline/sysstate.inl @@ -19,6 +19,19 @@ /*PAGE * + * _System_state_Handler_initialization + */ + +STATIC INLINE void _System_state_Handler_initialization ( + boolean is_multiprocessing +) +{ + _System_state_Current = SYSTEM_STATE_BEFORE_INITIALIZATION; + _System_state_Is_multiprocessing = is_multiprocessing; +} + +/*PAGE + * * _System_state_Set */ diff --git a/c/src/exec/score/inline/thread.inl b/c/src/exec/score/inline/thread.inl index 2a1049f241..e326410112 100644 --- a/c/src/exec/score/inline/thread.inl +++ b/c/src/exec/score/inline/thread.inl @@ -248,7 +248,7 @@ STATIC INLINE Thread_Control *_Thread_Get ( return( _Thread_Executing ); } - the_class = rtems_get_class( id ); + the_class = _Objects_Get_class( id ); if ( the_class > OBJECTS_CLASSES_LAST ) { *location = OBJECTS_ERROR; @@ -265,5 +265,17 @@ STATIC INLINE Thread_Control *_Thread_Get ( return (Thread_Control *) _Objects_Get( information, id, location ); } +/* + * _Thread_Is_proxy_blocking + * + */ + +STATIC INLINE boolean _Thread_Is_proxy_blocking ( + unsigned32 code +) +{ + return (code == THREAD_STATUS_PROXY_BLOCKING); +} + #endif /* end of include file */ diff --git a/c/src/exec/score/inline/tod.inl b/c/src/exec/score/inline/tod.inl index dadcdabcda..d2e26e2f2a 100644 --- a/c/src/exec/score/inline/tod.inl +++ b/c/src/exec/score/inline/tod.inl @@ -58,7 +58,7 @@ STATIC INLINE void _TOD_Deactivate( void ) */ STATIC INLINE void _TOD_Activate( - rtems_interval ticks + Watchdog_Interval ticks ) { _Watchdog_Insert_ticks( diff --git a/c/src/exec/score/inline/userext.inl b/c/src/exec/score/inline/userext.inl index fa5a31c37b..697a7eddd0 100644 --- a/c/src/exec/score/inline/userext.inl +++ b/c/src/exec/score/inline/userext.inl @@ -24,7 +24,7 @@ */ STATIC INLINE void _User_extensions_Handler_initialization ( - rtems_extensions_table *initial_extensions + User_extensions_Table *initial_extensions ) { _Chain_Initialize_empty( &_User_extensions_List ); @@ -42,7 +42,7 @@ STATIC INLINE void _User_extensions_Handler_initialization ( STATIC INLINE void _User_extensions_Add_set ( User_extensions_Control *the_extension, - rtems_extensions_table *extension_table + User_extensions_Table *extension_table ) { the_extension->Callouts = *extension_table; @@ -52,130 +52,35 @@ STATIC INLINE void _User_extensions_Add_set ( /*PAGE * - * _User_extensions_Remove_set - */ - -STATIC INLINE void _User_extensions_Remove_set ( - User_extensions_Control *the_extension -) -{ - _Chain_Extract( &the_extension->Node ); -} - -/*PAGE - * - * _User_extensions_Task_create - * + * _User_extensions_Add_API_set */ - -STATIC INLINE void _User_extensions_Task_create ( - Thread_Control *the_thread + +STATIC INLINE void _User_extensions_Add_API_set ( + User_extensions_Control *the_extension ) { - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.first ; - !_Chain_Is_tail( &_User_extensions_List, the_node ) ; - the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_create != NULL ) - (*the_extension->Callouts.rtems_task_create)( - _Thread_Executing, - the_thread - ); - } + _Chain_Prepend( &_User_extensions_List, &the_extension->Node ); } - + /*PAGE * - * _User_extensions_Task_delete - */ - -STATIC INLINE void _User_extensions_Task_delete ( - Thread_Control *the_thread -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.last ; - !_Chain_Is_head( &_User_extensions_List, the_node ) ; - the_node = the_node->previous ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_delete != NULL ) - (*the_extension->Callouts.rtems_task_delete)( - _Thread_Executing, - the_thread - ); - } -} - -/*PAGE - * - * _User_extensions_Task_start - * - */ - -STATIC INLINE void _User_extensions_Task_start ( - Thread_Control *the_thread -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.first ; - !_Chain_Is_tail( &_User_extensions_List, the_node ) ; - the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_start != NULL ) - (*the_extension->Callouts.rtems_task_start)( - _Thread_Executing, - the_thread - ); - } -} - -/*PAGE - * - * _User_extensions_Task_restart - * + * _User_extensions_Remove_set */ -STATIC INLINE void _User_extensions_Task_restart ( - Thread_Control *the_thread +STATIC INLINE void _User_extensions_Remove_set ( + User_extensions_Control *the_extension ) { - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.first ; - !_Chain_Is_tail( &_User_extensions_List, the_node ) ; - the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.rtems_task_restart != NULL ) - (*the_extension->Callouts.rtems_task_restart)( - _Thread_Executing, - the_thread - ); - } + _Chain_Extract( &the_extension->Node ); } /*PAGE * - * _User_extensions_Task_switch + * _User_extensions_Thread_switch * */ -STATIC INLINE void _User_extensions_Task_switch ( +STATIC INLINE void _User_extensions_Thread_switch ( Thread_Control *executing, Thread_Control *heir ) @@ -189,78 +94,32 @@ STATIC INLINE void _User_extensions_Task_switch ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.task_switch != NULL ) - (*the_extension->Callouts.task_switch)( executing, heir ); + if ( the_extension->Callouts.thread_switch != NULL ) + (*the_extension->Callouts.thread_switch)( executing, heir ); } } /*PAGE * - * _User_extensions_Task_begin + * _User_extensions_Thread_post_switch * */ - -STATIC INLINE void _User_extensions_Task_begin ( + +STATIC INLINE void _User_extensions_Thread_post_switch ( Thread_Control *executing ) { Chain_Node *the_node; User_extensions_Control *the_extension; - + for ( the_node = _User_extensions_List.first ; !_Chain_Is_tail( &_User_extensions_List, the_node ) ; the_node = the_node->next ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.task_begin != NULL ) - (*the_extension->Callouts.task_begin)( executing ); - } -} - -/*PAGE - * - * _User_extensions_Task_exitted - */ - -STATIC INLINE void _User_extensions_Task_exitted ( - Thread_Control *executing -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.last ; - !_Chain_Is_head( &_User_extensions_List, the_node ) ; - the_node = the_node->previous ) { - + the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.task_exitted != NULL ) - (*the_extension->Callouts.task_exitted)( executing ); - } -} - -/*PAGE - * - * _User_extensions_Fatal - */ - -STATIC INLINE void _User_extensions_Fatal ( - unsigned32 the_error -) -{ - Chain_Node *the_node; - User_extensions_Control *the_extension; - - for ( the_node = _User_extensions_List.last ; - !_Chain_Is_head( &_User_extensions_List, the_node ) ; - the_node = the_node->previous ) { - - the_extension = (User_extensions_Control *) the_node; - - if ( the_extension->Callouts.fatal != NULL ) - (*the_extension->Callouts.fatal)( the_error ); + + if ( the_extension->Callouts.thread_post_switch != NULL ) + (*the_extension->Callouts.thread_post_switch)( executing ); } } diff --git a/c/src/exec/score/inline/watchdog.inl b/c/src/exec/score/inline/watchdog.inl index 2e7dca0381..bb7edb82ed 100644 --- a/c/src/exec/score/inline/watchdog.inl +++ b/c/src/exec/score/inline/watchdog.inl @@ -24,10 +24,10 @@ */ STATIC INLINE void _Watchdog_Initialize( - Watchdog_Control *the_watchdog, - rtems_timer_service_routine_entry routine, - Objects_Id id, - void *user_data + Watchdog_Control *the_watchdog, + Watchdog_Service_routine_entry routine, + Objects_Id id, + void *user_data ) { the_watchdog->state = WATCHDOG_INACTIVE; @@ -115,7 +115,7 @@ STATIC INLINE void _Watchdog_Tickle_seconds( void ) STATIC INLINE void _Watchdog_Insert_ticks( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ) { @@ -134,7 +134,7 @@ STATIC INLINE void _Watchdog_Insert_ticks( STATIC INLINE void _Watchdog_Insert_seconds( Watchdog_Control *the_watchdog, - rtems_interval units, + Watchdog_Interval units, Watchdog_Insert_modes insert_mode ) { @@ -153,7 +153,7 @@ STATIC INLINE void _Watchdog_Insert_seconds( STATIC INLINE void _Watchdog_Adjust_seconds( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ) { @@ -169,7 +169,7 @@ STATIC INLINE void _Watchdog_Adjust_seconds( STATIC INLINE void _Watchdog_Adjust_ticks( Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ) { diff --git a/c/src/exec/score/inline/wkspace.inl b/c/src/exec/score/inline/wkspace.inl index 39d5ad8eb8..36ed61d565 100644 --- a/c/src/exec/score/inline/wkspace.inl +++ b/c/src/exec/score/inline/wkspace.inl @@ -1,7 +1,7 @@ /* wkspace.inl * * This include file contains the bodies of the routines which contains - * information related to the RTEMS RAM Workspace. + * information related to the RAM Workspace. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -32,9 +32,12 @@ STATIC INLINE void _Workspace_Handler_initialization( unsigned32 index; unsigned32 memory_available; - if ( (starting_address == NULL) || - !_Addresses_Is_aligned( starting_address ) ) - rtems_fatal_error_occurred( RTEMS_INVALID_ADDRESS ); + if ( !starting_address || !_Addresses_Is_aligned( starting_address ) ) + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS + ); if ( _CPU_Table.do_zero_of_workspace ) { for( zero_out_array = (unsigned32 *) starting_address, index = 0 ; @@ -51,7 +54,11 @@ STATIC INLINE void _Workspace_Handler_initialization( ); if ( memory_available == 0 ) - rtems_fatal_error_occurred( RTEMS_UNSATISFIED ); + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_TOO_LITTLE_WORKSPACE + ); } /*PAGE diff --git a/c/src/exec/score/macros/address.inl b/c/src/exec/score/macros/address.inl index f2672f2500..c0d45c3c6b 100644 --- a/c/src/exec/score/macros/address.inl +++ b/c/src/exec/score/macros/address.inl @@ -24,7 +24,7 @@ */ #define _Addresses_Add_offset( _base, _offset ) \ - ((void *)(_base) + (_offset)) + ((void *)((char *)(_base) + (_offset))) /*PAGE * @@ -33,18 +33,7 @@ */ #define _Addresses_Subtract_offset( _base, _offset ) \ - ((void *)(_base) - (_offset)) - -/*PAGE - * - * _Addresses_Add - * - * NOTE: The cast of an address to an unsigned32 makes this code - * dependent on an addresses being thirty two bits. - */ - -#define _Addresses_Add( _left, _right ) \ - ((void *)(_left) + (unsigned32)(_right)) + ((void *)((char *)(_base) - (_offset))) /*PAGE * diff --git a/c/src/exec/score/macros/coremutex.inl b/c/src/exec/score/macros/coremutex.inl new file mode 100644 index 0000000000..e8dbc9322c --- /dev/null +++ b/c/src/exec/score/macros/coremutex.inl @@ -0,0 +1,77 @@ +/* macros/coremutex.h + * + * This include file contains all of the inlined routines associated + * with core mutexes. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __MACROS_CORE_MUTEX_h +#define __MACROS_CORE_MUTEX_h + + +/*PAGE + * + * _CORE_mutex_Is_locked + * + */ + +#define _CORE_mutex_Is_locked( _the_mutex ) \ + ( (_the_mutex)->lock == CORE_MUTEX_LOCKED ) + +/*PAGE + * + * _CORE_mutex_Is_fifo + * + */ + +#define _CORE_mutex_Is_fifo( _the_attribute ) \ + ( (_the_attribute)->discipline == CORE_MUTEX_DISCIPLINES_FIFO ) + +/*PAGE + * + * _CORE_mutex_Is_priority + * + */ + +#define _CORE_mutex_Is_priority( _the_attribute ) \ + ( (_the_attribute)->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) + +/*PAGE + * + * _CORE_mutex_Is_inherit_priority + * + */ + +#define _CORE_mutex_Is_inherit_priority( _the_attribute ) \ + ( (_the_attribute)->discipline == \ + CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT ) + +/*PAGE + * + * _CORE_mutex_Is_priority_ceiling + * + */ + +#define _CORE_mutex_Is_priority_ceiling( _the_attribute )\ + ( (_the_attribute)->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING ) + +/*PAGE + * + * _CORE_mutex_Is_nesting_allowed + * + */ + +#define _CORE_mutex_Is_nesting_allowed( _the_attribute ) \ + ( (_the_attribute)->allow_nesting == TRUE ) + +#endif +/* end of include file */ diff --git a/c/src/exec/score/macros/coresem.inl b/c/src/exec/score/macros/coresem.inl new file mode 100644 index 0000000000..499b4a1433 --- /dev/null +++ b/c/src/exec/score/macros/coresem.inl @@ -0,0 +1,40 @@ +/* macros/coresem.h + * + * This include file contains all of the inlined routines associated + * with core semaphores. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __MACROS_CORE_SEMAPHORE_h +#define __MACROS_CORE_SEMAPHORE_h + +/*PAGE + * + * _CORE_semaphore_Is_priority + * + */ + +#define _CORE_semaphore_Is_priority( _the_attribute ) \ + ( (_the_attribute)->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ) + +/*PAGE + * + * _Core_semaphore_Get_count + * + */ + +#define _Core_semaphore_Get_count( _the_semaphore ) \ + ( (_the_semaphore)->count ) + + +#endif +/* end of include file */ diff --git a/c/src/exec/score/macros/heap.inl b/c/src/exec/score/macros/heap.inl index 4966aab385..1023a77fc5 100644 --- a/c/src/exec/score/macros/heap.inl +++ b/c/src/exec/score/macros/heap.inl @@ -17,7 +17,7 @@ #ifndef __HEAP_inl #define __HEAP_inl -#include <rtems/address.h> +#include <rtems/core/address.h> /*PAGE * diff --git a/c/src/exec/score/macros/isr.inl b/c/src/exec/score/macros/isr.inl index 93f234c7ff..975487c98b 100644 --- a/c/src/exec/score/macros/isr.inl +++ b/c/src/exec/score/macros/isr.inl @@ -19,18 +19,6 @@ /*PAGE * - * _ISR_Handler_initialization - * - */ - -#define _ISR_Handler_initialization() \ - { \ - _ISR_Signals_to_thread_executing = FALSE; \ - _ISR_Nest_level = 0; \ - } - -/*PAGE - * * _ISR_Is_in_progress * */ diff --git a/c/src/exec/score/macros/object.inl b/c/src/exec/score/macros/object.inl index 7a346af720..8a5a0a3411 100644 --- a/c/src/exec/score/macros/object.inl +++ b/c/src/exec/score/macros/object.inl @@ -30,29 +30,29 @@ /*PAGE * - * rtems_get_class + * _Objects_Get_class */ -#define rtems_get_class( _id ) \ +#define _Objects_Get_class( _id ) \ (Objects_Classes) \ (((_id) >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS) /*PAGE * - * rtems_get_node + * _Objects_Get_node * */ -#define rtems_get_node( _id ) \ +#define _Objects_Get_node( _id ) \ (((_id) >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS) /*PAGE * - * rtems_get_index + * _Objects_Get_index * */ -#define rtems_get_index( _id ) \ +#define _Objects_Get_index( _id ) \ (((_id) >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS) /*PAGE @@ -80,7 +80,7 @@ */ #define _Objects_Is_local_id( _id ) \ - _Objects_Is_local_node( rtems_get_node(_id) ) + _Objects_Is_local_node( _Objects_Get_node(_id) ) /*PAGE * @@ -119,7 +119,7 @@ { \ unsigned32 _index; \ \ - _index = rtems_get_index( (_the_object)->id ); \ + _index = _Objects_Get_index( (_the_object)->id ); \ (_information)->local_table[ _index ] = (_the_object); \ \ if ( (_information)->is_string ) \ @@ -139,7 +139,7 @@ { \ unsigned32 _index; \ \ - _index = rtems_get_index( (_the_object)->id ); \ + _index = _Objects_Get_index( (_the_object)->id ); \ (_information)->local_table[ _index ] = NULL; \ _Objects_Clear_name( (_the_object)->name, (_information)->name_length ); \ } diff --git a/c/src/exec/score/macros/priority.inl b/c/src/exec/score/macros/priority.inl index 0efec0050e..d78e2a0628 100644 --- a/c/src/exec/score/macros/priority.inl +++ b/c/src/exec/score/macros/priority.inl @@ -17,7 +17,7 @@ #ifndef __PRIORITY_inl #define __PRIORITY_inl -#include <rtems/bitfield.h> +#include <rtems/core/bitfield.h> /*PAGE * @@ -40,9 +40,13 @@ * */ + /* + * Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned, + * then checking for less than 0 is unnecessary. + */ + #define _Priority_Is_valid( _the_priority ) \ - ( ( (_the_priority) >= RTEMS_MINIMUM_PRIORITY ) && \ - ( (_the_priority) <= RTEMS_MAXIMUM_PRIORITY ) ) + ( (_the_priority) <= PRIORITY_MAXIMUM ) /*PAGE * diff --git a/c/src/exec/score/macros/rtems/score/address.inl b/c/src/exec/score/macros/rtems/score/address.inl index f2672f2500..c0d45c3c6b 100644 --- a/c/src/exec/score/macros/rtems/score/address.inl +++ b/c/src/exec/score/macros/rtems/score/address.inl @@ -24,7 +24,7 @@ */ #define _Addresses_Add_offset( _base, _offset ) \ - ((void *)(_base) + (_offset)) + ((void *)((char *)(_base) + (_offset))) /*PAGE * @@ -33,18 +33,7 @@ */ #define _Addresses_Subtract_offset( _base, _offset ) \ - ((void *)(_base) - (_offset)) - -/*PAGE - * - * _Addresses_Add - * - * NOTE: The cast of an address to an unsigned32 makes this code - * dependent on an addresses being thirty two bits. - */ - -#define _Addresses_Add( _left, _right ) \ - ((void *)(_left) + (unsigned32)(_right)) + ((void *)((char *)(_base) - (_offset))) /*PAGE * diff --git a/c/src/exec/score/macros/rtems/score/coremutex.inl b/c/src/exec/score/macros/rtems/score/coremutex.inl new file mode 100644 index 0000000000..e8dbc9322c --- /dev/null +++ b/c/src/exec/score/macros/rtems/score/coremutex.inl @@ -0,0 +1,77 @@ +/* macros/coremutex.h + * + * This include file contains all of the inlined routines associated + * with core mutexes. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __MACROS_CORE_MUTEX_h +#define __MACROS_CORE_MUTEX_h + + +/*PAGE + * + * _CORE_mutex_Is_locked + * + */ + +#define _CORE_mutex_Is_locked( _the_mutex ) \ + ( (_the_mutex)->lock == CORE_MUTEX_LOCKED ) + +/*PAGE + * + * _CORE_mutex_Is_fifo + * + */ + +#define _CORE_mutex_Is_fifo( _the_attribute ) \ + ( (_the_attribute)->discipline == CORE_MUTEX_DISCIPLINES_FIFO ) + +/*PAGE + * + * _CORE_mutex_Is_priority + * + */ + +#define _CORE_mutex_Is_priority( _the_attribute ) \ + ( (_the_attribute)->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY ) + +/*PAGE + * + * _CORE_mutex_Is_inherit_priority + * + */ + +#define _CORE_mutex_Is_inherit_priority( _the_attribute ) \ + ( (_the_attribute)->discipline == \ + CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT ) + +/*PAGE + * + * _CORE_mutex_Is_priority_ceiling + * + */ + +#define _CORE_mutex_Is_priority_ceiling( _the_attribute )\ + ( (_the_attribute)->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING ) + +/*PAGE + * + * _CORE_mutex_Is_nesting_allowed + * + */ + +#define _CORE_mutex_Is_nesting_allowed( _the_attribute ) \ + ( (_the_attribute)->allow_nesting == TRUE ) + +#endif +/* end of include file */ diff --git a/c/src/exec/score/macros/rtems/score/coresem.inl b/c/src/exec/score/macros/rtems/score/coresem.inl new file mode 100644 index 0000000000..499b4a1433 --- /dev/null +++ b/c/src/exec/score/macros/rtems/score/coresem.inl @@ -0,0 +1,40 @@ +/* macros/coresem.h + * + * This include file contains all of the inlined routines associated + * with core semaphores. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#ifndef __MACROS_CORE_SEMAPHORE_h +#define __MACROS_CORE_SEMAPHORE_h + +/*PAGE + * + * _CORE_semaphore_Is_priority + * + */ + +#define _CORE_semaphore_Is_priority( _the_attribute ) \ + ( (_the_attribute)->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ) + +/*PAGE + * + * _Core_semaphore_Get_count + * + */ + +#define _Core_semaphore_Get_count( _the_semaphore ) \ + ( (_the_semaphore)->count ) + + +#endif +/* end of include file */ diff --git a/c/src/exec/score/macros/rtems/score/heap.inl b/c/src/exec/score/macros/rtems/score/heap.inl index 4966aab385..1023a77fc5 100644 --- a/c/src/exec/score/macros/rtems/score/heap.inl +++ b/c/src/exec/score/macros/rtems/score/heap.inl @@ -17,7 +17,7 @@ #ifndef __HEAP_inl #define __HEAP_inl -#include <rtems/address.h> +#include <rtems/core/address.h> /*PAGE * diff --git a/c/src/exec/score/macros/rtems/score/isr.inl b/c/src/exec/score/macros/rtems/score/isr.inl index 93f234c7ff..975487c98b 100644 --- a/c/src/exec/score/macros/rtems/score/isr.inl +++ b/c/src/exec/score/macros/rtems/score/isr.inl @@ -19,18 +19,6 @@ /*PAGE * - * _ISR_Handler_initialization - * - */ - -#define _ISR_Handler_initialization() \ - { \ - _ISR_Signals_to_thread_executing = FALSE; \ - _ISR_Nest_level = 0; \ - } - -/*PAGE - * * _ISR_Is_in_progress * */ diff --git a/c/src/exec/score/macros/rtems/score/object.inl b/c/src/exec/score/macros/rtems/score/object.inl index 7a346af720..8a5a0a3411 100644 --- a/c/src/exec/score/macros/rtems/score/object.inl +++ b/c/src/exec/score/macros/rtems/score/object.inl @@ -30,29 +30,29 @@ /*PAGE * - * rtems_get_class + * _Objects_Get_class */ -#define rtems_get_class( _id ) \ +#define _Objects_Get_class( _id ) \ (Objects_Classes) \ (((_id) >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS) /*PAGE * - * rtems_get_node + * _Objects_Get_node * */ -#define rtems_get_node( _id ) \ +#define _Objects_Get_node( _id ) \ (((_id) >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS) /*PAGE * - * rtems_get_index + * _Objects_Get_index * */ -#define rtems_get_index( _id ) \ +#define _Objects_Get_index( _id ) \ (((_id) >> OBJECTS_INDEX_START_BIT) & OBJECTS_INDEX_VALID_BITS) /*PAGE @@ -80,7 +80,7 @@ */ #define _Objects_Is_local_id( _id ) \ - _Objects_Is_local_node( rtems_get_node(_id) ) + _Objects_Is_local_node( _Objects_Get_node(_id) ) /*PAGE * @@ -119,7 +119,7 @@ { \ unsigned32 _index; \ \ - _index = rtems_get_index( (_the_object)->id ); \ + _index = _Objects_Get_index( (_the_object)->id ); \ (_information)->local_table[ _index ] = (_the_object); \ \ if ( (_information)->is_string ) \ @@ -139,7 +139,7 @@ { \ unsigned32 _index; \ \ - _index = rtems_get_index( (_the_object)->id ); \ + _index = _Objects_Get_index( (_the_object)->id ); \ (_information)->local_table[ _index ] = NULL; \ _Objects_Clear_name( (_the_object)->name, (_information)->name_length ); \ } diff --git a/c/src/exec/score/macros/rtems/score/priority.inl b/c/src/exec/score/macros/rtems/score/priority.inl index 0efec0050e..d78e2a0628 100644 --- a/c/src/exec/score/macros/rtems/score/priority.inl +++ b/c/src/exec/score/macros/rtems/score/priority.inl @@ -17,7 +17,7 @@ #ifndef __PRIORITY_inl #define __PRIORITY_inl -#include <rtems/bitfield.h> +#include <rtems/core/bitfield.h> /*PAGE * @@ -40,9 +40,13 @@ * */ + /* + * Since PRIORITY_MINIMUM is 0 and priorities are stored unsigned, + * then checking for less than 0 is unnecessary. + */ + #define _Priority_Is_valid( _the_priority ) \ - ( ( (_the_priority) >= RTEMS_MINIMUM_PRIORITY ) && \ - ( (_the_priority) <= RTEMS_MAXIMUM_PRIORITY ) ) + ( (_the_priority) <= PRIORITY_MAXIMUM ) /*PAGE * diff --git a/c/src/exec/score/macros/rtems/score/stack.inl b/c/src/exec/score/macros/rtems/score/stack.inl index 208503b45f..d20eebd0b9 100644 --- a/c/src/exec/score/macros/rtems/score/stack.inl +++ b/c/src/exec/score/macros/rtems/score/stack.inl @@ -36,7 +36,7 @@ */ #define _Stack_Is_enough( _size ) \ - ( (_size) >= RTEMS_MINIMUM_STACK_SIZE ) + ( (_size) >= STACK_MINIMUM_SIZE ) /*PAGE * diff --git a/c/src/exec/score/macros/rtems/score/states.inl b/c/src/exec/score/macros/rtems/score/states.inl index f69c4ba042..4fa138d107 100644 --- a/c/src/exec/score/macros/rtems/score/states.inl +++ b/c/src/exec/score/macros/rtems/score/states.inl @@ -1,7 +1,7 @@ /* states.inl * * This file contains the macro implementation of the inlined - * routines associated with RTEMS state information. + * routines associated with thread state information. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -127,6 +127,15 @@ /*PAGE * + * _States_Is_waiting_for_mutex + * + */ + +#define _States_Is_waiting_for_mutex( _the_states ) \ + ( (_the_states) & STATES_WAITING_FOR_MUTEX ) + +/*PAGE + * * _States_Is_waiting_for_semaphore * */ diff --git a/c/src/exec/score/macros/rtems/score/sysstate.inl b/c/src/exec/score/macros/rtems/score/sysstate.inl index ed13494d30..d0cb932924 100644 --- a/c/src/exec/score/macros/rtems/score/sysstate.inl +++ b/c/src/exec/score/macros/rtems/score/sysstate.inl @@ -19,11 +19,24 @@ /*PAGE * + * _System_state_Handler_initialization + */ + +#define _System_state_Handler_initialization( _is_multiprocessing ) \ + do { \ + _System_state_Current = SYSTEM_STATE_BEFORE_INITIALIZATION; \ + _System_state_Is_multiprocessing = (_is_multiprocessing); \ + } while ( 0 ) + +/*PAGE + * * _System_state_Set */ #define _System_state_Set( _state ) \ - _System_state_Current = (_state) + do { \ + _System_state_Current = (_state); \ + } while ( 0 ) /*PAGE * diff --git a/c/src/exec/score/macros/rtems/score/thread.inl b/c/src/exec/score/macros/rtems/score/thread.inl index d7d37cb218..3f7afb054b 100644 --- a/c/src/exec/score/macros/rtems/score/thread.inl +++ b/c/src/exec/score/macros/rtems/score/thread.inl @@ -189,5 +189,13 @@ void _Thread_Enable_dispatch( void ); #define _Thread_Is_null( _the_thread ) \ ( (_the_thread) == NULL ) +/* + * _Thread_Is_proxy_blocking + * + */ + +#define _Thread_Is_proxy_blocking( _code ) \ + ( (_code) == THREAD_STATUS_PROXY_BLOCKING ) + #endif /* end of include file */ diff --git a/c/src/exec/score/macros/rtems/score/userext.inl b/c/src/exec/score/macros/rtems/score/userext.inl index 781f30ad40..2daa37494d 100644 --- a/c/src/exec/score/macros/rtems/score/userext.inl +++ b/c/src/exec/score/macros/rtems/score/userext.inl @@ -40,11 +40,20 @@ */ #define _User_extensions_Add_set( _the_extension, _extension_table ) \ - { \ + do { \ (_the_extension)->Callouts = *(_extension_table); \ \ _Chain_Append( &_User_extensions_List, &(_the_extension)->Node ); \ - } + } while ( 0 ) + +/*PAGE + * + * _User_extensions_Add_API_set + */ + +#define _User_extensions_Add_API_set( _the_extension ) \ + _Chain_Prepend( &_User_extensions_List, &(_the_extension)->Node ) + /*PAGE * @@ -106,79 +115,21 @@ /*PAGE * - * _User_extensions_Task_create - * - */ - -#define _User_extensions_Task_create( _the_thread ) \ - _User_extensions_Run_list_forward(rtems_task_create, \ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_delete - * - */ - -#define _User_extensions_Task_delete( _the_thread ) \ - _User_extensions_Run_list_backward(rtems_task_delete, \ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_start - * - */ - -#define _User_extensions_Task_start( _the_thread ) \ - _User_extensions_Run_list_forward(rtems_task_start, \ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_restart - * - */ - -#define _User_extensions_Task_restart( _the_thread ) \ - _User_extensions_Run_list_forward(rtems_task_restart,\ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_switch - * - */ - -#define _User_extensions_Task_switch( _executing, _heir ) \ - _User_extensions_Run_list_forward(task_switch, (_executing, _heir) ) - -/*PAGE - * - * _User_extensions_Task_begin - * - */ - -#define _User_extensions_Task_begin( _executing ) \ - _User_extensions_Run_list_forward(task_begin, (_executing) ) - -/*PAGE - * - * _User_extensions_Task_exitted + * _User_extensions_Thread_switch * */ -#define _User_extensions_Task_exitted( _executing ) \ - _User_extensions_Run_list_backward(task_exitted, (_executing) ) +#define _User_extensions_Thread_switch( _executing, _heir ) \ + _User_extensions_Run_list_forward(thread_switch, (_executing, _heir) ) /*PAGE * - * _User_extensions_Fatal + * _User_extensions_Thread_post_switch * */ -#define _User_extensions_Fatal( _the_error ) \ - _User_extensions_Run_list_backward(fatal, (_the_error) ) +#define _User_extensions_Thread_post_switch( _executing ) \ + _User_extensions_Run_list_forward(thread_post_switch, (_executing) ) #endif /* end of include file */ diff --git a/c/src/exec/score/macros/rtems/score/watchdog.inl b/c/src/exec/score/macros/rtems/score/watchdog.inl index 4e965420ce..15023722c6 100644 --- a/c/src/exec/score/macros/rtems/score/watchdog.inl +++ b/c/src/exec/score/macros/rtems/score/watchdog.inl @@ -17,7 +17,7 @@ #ifndef __WATCHDOG_inl #define __WATCHDOG_inl -#include <rtems/object.h> +#include <rtems/core/object.h> /*PAGE * diff --git a/c/src/exec/score/macros/rtems/score/wkspace.inl b/c/src/exec/score/macros/rtems/score/wkspace.inl index 1139e188db..aa6ccc0440 100644 --- a/c/src/exec/score/macros/rtems/score/wkspace.inl +++ b/c/src/exec/score/macros/rtems/score/wkspace.inl @@ -1,7 +1,7 @@ /* wkspace.inl * * This file contains the macro implementation of the inlined routines - * from the RTEMS RAM Workspace Handler. + * from the RAM Workspace Handler. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -17,10 +17,6 @@ #ifndef __WORKSPACE_inl #define __WORKSPACE_inl -#include <rtems/heap.h> -#include <rtems/fatal.h> -#include <rtems/status.h> - /*PAGE * * _Workspace_Handler_initialization @@ -33,9 +29,12 @@ unsigned32 index; \ unsigned32 memory_available; \ \ - if ( ((_starting_address) == NULL) || \ - !_Addresses_Is_aligned( (_starting_address) ) ) \ - rtems_fatal_error_occurred( RTEMS_INVALID_ADDRESS ); \ + if ( !(_starting_address) || !_Addresses_Is_aligned( (_starting_address) ) ) \ + _Internal_error_Occurred( \ + INTERNAL_ERROR_CORE, \ + TRUE, \ + INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS \ + ); \ \ if ( _CPU_Table.do_zero_of_workspace ) { \ for( zero_out_array = (unsigned32 *) (_starting_address), index = 0 ; \ @@ -52,7 +51,11 @@ ); \ \ if ( memory_available == 0 ) \ - rtems_fatal_error_occurred( RTEMS_UNSATISFIED ); \ + _Internal_error_Occurred( \ + INTERNAL_ERROR_CORE, \ + TRUE, \ + INTERNAL_ERROR_TOO_LITTLE_WORKSPACE \ + ); \ } /*PAGE diff --git a/c/src/exec/score/macros/stack.inl b/c/src/exec/score/macros/stack.inl index 208503b45f..d20eebd0b9 100644 --- a/c/src/exec/score/macros/stack.inl +++ b/c/src/exec/score/macros/stack.inl @@ -36,7 +36,7 @@ */ #define _Stack_Is_enough( _size ) \ - ( (_size) >= RTEMS_MINIMUM_STACK_SIZE ) + ( (_size) >= STACK_MINIMUM_SIZE ) /*PAGE * diff --git a/c/src/exec/score/macros/states.inl b/c/src/exec/score/macros/states.inl index f69c4ba042..4fa138d107 100644 --- a/c/src/exec/score/macros/states.inl +++ b/c/src/exec/score/macros/states.inl @@ -1,7 +1,7 @@ /* states.inl * * This file contains the macro implementation of the inlined - * routines associated with RTEMS state information. + * routines associated with thread state information. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -127,6 +127,15 @@ /*PAGE * + * _States_Is_waiting_for_mutex + * + */ + +#define _States_Is_waiting_for_mutex( _the_states ) \ + ( (_the_states) & STATES_WAITING_FOR_MUTEX ) + +/*PAGE + * * _States_Is_waiting_for_semaphore * */ diff --git a/c/src/exec/score/macros/sysstate.inl b/c/src/exec/score/macros/sysstate.inl index ed13494d30..d0cb932924 100644 --- a/c/src/exec/score/macros/sysstate.inl +++ b/c/src/exec/score/macros/sysstate.inl @@ -19,11 +19,24 @@ /*PAGE * + * _System_state_Handler_initialization + */ + +#define _System_state_Handler_initialization( _is_multiprocessing ) \ + do { \ + _System_state_Current = SYSTEM_STATE_BEFORE_INITIALIZATION; \ + _System_state_Is_multiprocessing = (_is_multiprocessing); \ + } while ( 0 ) + +/*PAGE + * * _System_state_Set */ #define _System_state_Set( _state ) \ - _System_state_Current = (_state) + do { \ + _System_state_Current = (_state); \ + } while ( 0 ) /*PAGE * diff --git a/c/src/exec/score/macros/thread.inl b/c/src/exec/score/macros/thread.inl index d7d37cb218..3f7afb054b 100644 --- a/c/src/exec/score/macros/thread.inl +++ b/c/src/exec/score/macros/thread.inl @@ -189,5 +189,13 @@ void _Thread_Enable_dispatch( void ); #define _Thread_Is_null( _the_thread ) \ ( (_the_thread) == NULL ) +/* + * _Thread_Is_proxy_blocking + * + */ + +#define _Thread_Is_proxy_blocking( _code ) \ + ( (_code) == THREAD_STATUS_PROXY_BLOCKING ) + #endif /* end of include file */ diff --git a/c/src/exec/score/macros/userext.inl b/c/src/exec/score/macros/userext.inl index 781f30ad40..2daa37494d 100644 --- a/c/src/exec/score/macros/userext.inl +++ b/c/src/exec/score/macros/userext.inl @@ -40,11 +40,20 @@ */ #define _User_extensions_Add_set( _the_extension, _extension_table ) \ - { \ + do { \ (_the_extension)->Callouts = *(_extension_table); \ \ _Chain_Append( &_User_extensions_List, &(_the_extension)->Node ); \ - } + } while ( 0 ) + +/*PAGE + * + * _User_extensions_Add_API_set + */ + +#define _User_extensions_Add_API_set( _the_extension ) \ + _Chain_Prepend( &_User_extensions_List, &(_the_extension)->Node ) + /*PAGE * @@ -106,79 +115,21 @@ /*PAGE * - * _User_extensions_Task_create - * - */ - -#define _User_extensions_Task_create( _the_thread ) \ - _User_extensions_Run_list_forward(rtems_task_create, \ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_delete - * - */ - -#define _User_extensions_Task_delete( _the_thread ) \ - _User_extensions_Run_list_backward(rtems_task_delete, \ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_start - * - */ - -#define _User_extensions_Task_start( _the_thread ) \ - _User_extensions_Run_list_forward(rtems_task_start, \ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_restart - * - */ - -#define _User_extensions_Task_restart( _the_thread ) \ - _User_extensions_Run_list_forward(rtems_task_restart,\ - (_Thread_Executing, _the_thread) ) - -/*PAGE - * - * _User_extensions_Task_switch - * - */ - -#define _User_extensions_Task_switch( _executing, _heir ) \ - _User_extensions_Run_list_forward(task_switch, (_executing, _heir) ) - -/*PAGE - * - * _User_extensions_Task_begin - * - */ - -#define _User_extensions_Task_begin( _executing ) \ - _User_extensions_Run_list_forward(task_begin, (_executing) ) - -/*PAGE - * - * _User_extensions_Task_exitted + * _User_extensions_Thread_switch * */ -#define _User_extensions_Task_exitted( _executing ) \ - _User_extensions_Run_list_backward(task_exitted, (_executing) ) +#define _User_extensions_Thread_switch( _executing, _heir ) \ + _User_extensions_Run_list_forward(thread_switch, (_executing, _heir) ) /*PAGE * - * _User_extensions_Fatal + * _User_extensions_Thread_post_switch * */ -#define _User_extensions_Fatal( _the_error ) \ - _User_extensions_Run_list_backward(fatal, (_the_error) ) +#define _User_extensions_Thread_post_switch( _executing ) \ + _User_extensions_Run_list_forward(thread_post_switch, (_executing) ) #endif /* end of include file */ diff --git a/c/src/exec/score/macros/watchdog.inl b/c/src/exec/score/macros/watchdog.inl index 4e965420ce..15023722c6 100644 --- a/c/src/exec/score/macros/watchdog.inl +++ b/c/src/exec/score/macros/watchdog.inl @@ -17,7 +17,7 @@ #ifndef __WATCHDOG_inl #define __WATCHDOG_inl -#include <rtems/object.h> +#include <rtems/core/object.h> /*PAGE * diff --git a/c/src/exec/score/macros/wkspace.inl b/c/src/exec/score/macros/wkspace.inl index 1139e188db..aa6ccc0440 100644 --- a/c/src/exec/score/macros/wkspace.inl +++ b/c/src/exec/score/macros/wkspace.inl @@ -1,7 +1,7 @@ /* wkspace.inl * * This file contains the macro implementation of the inlined routines - * from the RTEMS RAM Workspace Handler. + * from the RAM Workspace Handler. * * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. * On-Line Applications Research Corporation (OAR). @@ -17,10 +17,6 @@ #ifndef __WORKSPACE_inl #define __WORKSPACE_inl -#include <rtems/heap.h> -#include <rtems/fatal.h> -#include <rtems/status.h> - /*PAGE * * _Workspace_Handler_initialization @@ -33,9 +29,12 @@ unsigned32 index; \ unsigned32 memory_available; \ \ - if ( ((_starting_address) == NULL) || \ - !_Addresses_Is_aligned( (_starting_address) ) ) \ - rtems_fatal_error_occurred( RTEMS_INVALID_ADDRESS ); \ + if ( !(_starting_address) || !_Addresses_Is_aligned( (_starting_address) ) ) \ + _Internal_error_Occurred( \ + INTERNAL_ERROR_CORE, \ + TRUE, \ + INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS \ + ); \ \ if ( _CPU_Table.do_zero_of_workspace ) { \ for( zero_out_array = (unsigned32 *) (_starting_address), index = 0 ; \ @@ -52,7 +51,11 @@ ); \ \ if ( memory_available == 0 ) \ - rtems_fatal_error_occurred( RTEMS_UNSATISFIED ); \ + _Internal_error_Occurred( \ + INTERNAL_ERROR_CORE, \ + TRUE, \ + INTERNAL_ERROR_TOO_LITTLE_WORKSPACE \ + ); \ } /*PAGE diff --git a/c/src/exec/score/src/chain.c b/c/src/exec/score/src/chain.c index 88f6759b0b..3cea8ea90f 100644 --- a/c/src/exec/score/src/chain.c +++ b/c/src/exec/score/src/chain.c @@ -18,9 +18,9 @@ */ #include <rtems/system.h> -#include <rtems/address.h> -#include <rtems/chain.h> -#include <rtems/isr.h> +#include <rtems/core/address.h> +#include <rtems/core/chain.h> +#include <rtems/core/isr.h> /*PAGE * diff --git a/c/src/exec/score/src/coremutex.c b/c/src/exec/score/src/coremutex.c new file mode 100644 index 0000000000..ea2b5773e1 --- /dev/null +++ b/c/src/exec/score/src/coremutex.c @@ -0,0 +1,269 @@ +/* + * Mutex Handler + * + * DESCRIPTION: + * + * This package is the implementation of the Mutex Handler. + * This handler provides synchronization and mutual exclusion capabilities. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include <rtems/system.h> +#include <rtems/core/isr.h> +#include <rtems/core/coremutex.h> +#include <rtems/core/states.h> +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> + +/*PAGE + * + * _CORE_mutex_Initialize + * + * This routine initializes a mutex at create time and set the control + * structure according to the values passed. + * + * Input parameters: + * the_mutex - the mutex control block to initialize + * the_class - the API class of the object + * the_mutex_attributes - the mutex attributes specified at create time + * initial_lock - mutex initial lock or unlocked status + * proxy_extract_callout - MP specific extract callout + * + * Output parameters: NONE + */ + +void _CORE_mutex_Initialize( + CORE_mutex_Control *the_mutex, + Objects_Classes the_class, + CORE_mutex_Attributes *the_mutex_attributes, + unsigned32 initial_lock, + Thread_queue_Extract_callout proxy_extract_callout +) +{ + +/* Add this to the RTEMS environment later ????????? + rtems_assert( initial_lock == CORE_MUTEX_LOCKED || + initial_lock == CORE_MUTEX_UNLOCKED ); + */ + + the_mutex->Attributes = *the_mutex_attributes; + the_mutex->lock = initial_lock; + + if ( initial_lock == CORE_MUTEX_LOCKED ) { + the_mutex->nest_count = 1; + the_mutex->holder = _Thread_Executing; + the_mutex->holder_id = _Thread_Executing->Object.id; + _Thread_Executing->resource_count++; + } else { + the_mutex->nest_count = 0; + the_mutex->holder = NULL; + the_mutex->holder_id = 0; + } + + _Thread_queue_Initialize( + &the_mutex->Wait_queue, + the_class, + _CORE_mutex_Is_priority( the_mutex_attributes ) ? + THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO, + STATES_WAITING_FOR_MUTEX, + proxy_extract_callout, + CORE_MUTEX_TIMEOUT + ); +} + +/*PAGE + * + * _CORE_mutex_Seize + * + * This routine attempts to allocate a mutex to the calling thread. + * + * Input parameters: + * the_mutex - pointer to mutex control block + * id - id of object to wait on + * wait - TRUE if wait is allowed, FALSE otherwise + * timeout - number of ticks to wait (0 means forever) + * + * Output parameters: NONE + * + * INTERRUPT LATENCY: + * available + * wait + */ + +void _CORE_mutex_Seize( + CORE_mutex_Control *the_mutex, + Objects_Id id, + boolean wait, + Watchdog_Interval timeout +) +{ + Thread_Control *executing; + ISR_Level level; + + executing = _Thread_Executing; + executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL; + _ISR_Disable( level ); + if ( ! _CORE_mutex_Is_locked( the_mutex ) ) { + the_mutex->lock = CORE_MUTEX_LOCKED; + the_mutex->holder = executing; + the_mutex->holder_id = executing->Object.id; + the_mutex->nest_count = 1; + executing->resource_count++; + _ISR_Enable( level ); + return; + } + + if ( !wait ) { + _ISR_Enable( level ); + executing->Wait.return_code = CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT; + return; + } + + if ( _Objects_Are_ids_equal( + _Thread_Executing->Object.id, the_mutex->holder_id ) ) { + if ( _CORE_mutex_Is_nesting_allowed( &the_mutex->Attributes ) ) + the_mutex->nest_count++; + else + executing->Wait.return_code = CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED; + + _ISR_Enable( level ); + return; + } + + the_mutex->Wait_queue.sync = TRUE; + executing->Wait.queue = &the_mutex->Wait_queue; + executing->Wait.id = id; + _ISR_Enable( level ); + + if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) && + the_mutex->holder->current_priority > + _Thread_Executing->current_priority ) { + _Thread_Change_priority( + the_mutex->holder, _Thread_Executing->current_priority ); + } + + _Thread_queue_Enqueue( &the_mutex->Wait_queue, timeout ); +} + +/* + * _CORE_mutex_Surrender + * + * DESCRIPTION: + * + * This routine frees a unit to the mutex. If a task was blocked waiting for + * a unit from this mutex, then that task will be readied and the unit + * given to that task. Otherwise, the unit will be returned to the mutex. + * + * Input parameters: + * the_mutex - the mutex to be flushed + * id - id of parent mutex + * api_mutex_mp_support - api dependent MP support actions + * + * Output parameters: + * CORE_MUTEX_STATUS_SUCCESSFUL - if successful + * core error code - if unsuccessful + */ + +CORE_mutex_Status _CORE_mutex_Surrender( + CORE_mutex_Control *the_mutex, + Objects_Id id, + CORE_mutex_API_mp_support_callout api_mutex_mp_support +) +{ + Thread_Control *the_thread; + + if ( !_Objects_Are_ids_equal( + _Thread_Executing->Object.id, the_mutex->holder_id ) ) + return( CORE_MUTEX_STATUS_NOT_OWNER_OF_RESOURCE ); + + the_mutex->nest_count--; + + if ( the_mutex->nest_count != 0 ) + return( CORE_MUTEX_STATUS_SUCCESSFUL ); + + _Thread_Executing->resource_count--; + the_mutex->holder = NULL; + the_mutex->holder_id = 0; + + /* + * Whether or not someone is waiting for the mutex, an + * inherited priority must be lowered if this is the last + * mutex (i.e. resource) this task has. + */ + + if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) && + _Thread_Executing->resource_count == 0 && + _Thread_Executing->real_priority != + _Thread_Executing->current_priority ) { + _Thread_Change_priority( + _Thread_Executing, + _Thread_Executing->real_priority + ); + } + + if ( ( the_thread = _Thread_queue_Dequeue( &the_mutex->Wait_queue ) ) ) { + + if ( !_Objects_Is_local_id( the_thread->Object.id ) ) { + + the_mutex->holder = NULL; + the_mutex->holder_id = the_thread->Object.id; + the_mutex->nest_count = 1; + + ( *api_mutex_mp_support)( the_thread, id ); + + } else { + + the_mutex->holder = the_thread; + the_mutex->holder_id = the_thread->Object.id; + the_thread->resource_count++; + the_mutex->nest_count = 1; + + /* + * No special action for priority inheritance because the_thread + * is guaranteed to be the highest priority thread waiting for + * the mutex. + */ + } + } else + the_mutex->lock = CORE_MUTEX_UNLOCKED; + + return( CORE_MUTEX_STATUS_SUCCESSFUL ); +} + +/*PAGE + * + * _CORE_mutex_Flush + * + * This function a flushes the mutex's task wait queue. + * + * Input parameters: + * the_mutex - the mutex to be flushed + * remote_extract_callout - function to invoke remotely + * status - status to pass to thread + * + * Output parameters: NONE + */ + +void _CORE_mutex_Flush( + CORE_mutex_Control *the_mutex, + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status +) +{ + + _Thread_queue_Flush( + &the_mutex->Wait_queue, + remote_extract_callout, + status + ); + +} diff --git a/c/src/exec/score/src/coresem.c b/c/src/exec/score/src/coresem.c new file mode 100644 index 0000000000..e7e1705f3c --- /dev/null +++ b/c/src/exec/score/src/coresem.c @@ -0,0 +1,185 @@ +/* + * CORE Semaphore Handler + * + * DESCRIPTION: + * + * This package is the implementation of the CORE Semaphore Handler. + * This core object utilizes standard Dijkstra counting semaphores to provide + * synchronization and mutual exclusion capabilities. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include <rtems/system.h> +#include <rtems/core/isr.h> +#include <rtems/core/coresem.h> +#include <rtems/core/states.h> +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/mpci.h> + +/*PAGE + * + * CORE_semaphore_Initialize + * + * This function initialize a semaphore and sets the initial value based + * on the given count. + * + * Input parameters: + * the_semaphore - the semaphore control block to initialize + * the_class - the API class of the object + * the_semaphore_attributes - the attributes specified at create time + * initial_value - semaphore's initial value + * proxy_extract_callout - MP specific extract callout + * + * Output parameters: NONE + */ + +void _CORE_semaphore_Initialize( + CORE_semaphore_Control *the_semaphore, + Objects_Classes the_class, + CORE_semaphore_Attributes *the_semaphore_attributes, + unsigned32 initial_value, + Thread_queue_Extract_callout proxy_extract_callout +) +{ + + the_semaphore->Attributes = *the_semaphore_attributes; + the_semaphore->count = initial_value; + + _Thread_queue_Initialize( + &the_semaphore->Wait_queue, + the_class, + _CORE_semaphore_Is_priority( the_semaphore_attributes ) ? + THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO, + STATES_WAITING_FOR_SEMAPHORE, + proxy_extract_callout, + CORE_SEMAPHORE_TIMEOUT + ); +} + +/*PAGE + * + * _CORE_semaphore_Surrender + * + * Input parameters: + * the_semaphore - the semaphore to be flushed + * id - id of parent semaphore + * api_semaphore_mp_support - api dependent MP support actions + * + * Output parameters: + * CORE_SEMAPHORE_STATUS_SUCCESSFUL - if successful + * core error code - if unsuccessful + * + * Output parameters: + */ + +CORE_semaphore_Status _CORE_semaphore_Surrender( + CORE_semaphore_Control *the_semaphore, + Objects_Id id, + CORE_semaphore_API_mp_support_callout api_semaphore_mp_support +) +{ + Thread_Control *the_thread; + + if ( (the_thread = _Thread_queue_Dequeue(&the_semaphore->Wait_queue)) ) { + + if ( !_Objects_Is_local_id( the_thread->Object.id ) ) + (*api_semaphore_mp_support) ( the_thread, id ); + + } else + the_semaphore->count += 1; + + return( CORE_SEMAPHORE_STATUS_SUCCESSFUL ); +} + +/*PAGE + * + * _CORE_semaphore_Seize + * + * This routine attempts to allocate a core semaphore to the calling thread. + * + * Input parameters: + * the_semaphore - pointer to semaphore control block + * id - id of object to wait on + * wait - TRUE if wait is allowed, FALSE otherwise + * timeout - number of ticks to wait (0 means forever) + * + * Output parameters: NONE + * + * INTERRUPT LATENCY: + * available + * wait + */ + +void _CORE_semaphore_Seize( + CORE_semaphore_Control *the_semaphore, + Objects_Id id, + boolean wait, + Watchdog_Interval timeout +) +{ + Thread_Control *executing; + ISR_Level level; + + executing = _Thread_Executing; + executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL; + _ISR_Disable( level ); + if ( the_semaphore->count != 0 ) { + the_semaphore->count -= 1; + executing->resource_count++; + _ISR_Enable( level ); + return; + } + + if ( !wait ) { + _ISR_Enable( level ); + executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; + return; + } + + the_semaphore->Wait_queue.sync = TRUE; + executing->Wait.queue = &the_semaphore->Wait_queue; + executing->Wait.id = id; + _ISR_Enable( level ); + + _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout ); +} + + +/*PAGE + * + * _CORE_semaphore_Flush + * + * This function a flushes the semaphore's task wait queue. + * + * Input parameters: + * the_semaphore - the semaphore to be flushed + * remote_extract_callout - function to invoke remotely + * status - status to pass to thread + * + * Output parameters: NONE + */ + +void _CORE_semaphore_Flush( + CORE_semaphore_Control *the_semaphore, + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status +) +{ + + _Thread_queue_Flush( + &the_semaphore->Wait_queue, + remote_extract_callout, + status + ); + +} diff --git a/c/src/exec/score/src/coretod.c b/c/src/exec/score/src/coretod.c index 4689c637d7..ab464664f6 100644 --- a/c/src/exec/score/src/coretod.c +++ b/c/src/exec/score/src/coretod.c @@ -14,10 +14,10 @@ */ #include <rtems/system.h> -#include <rtems/object.h> -#include <rtems/thread.h> -#include <rtems/tod.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/thread.h> +#include <rtems/core/tod.h> +#include <rtems/core/watchdog.h> /*PAGE * @@ -72,11 +72,11 @@ void _TOD_Handler_initialization( */ void _TOD_Set( - rtems_time_of_day *the_tod, - rtems_interval seconds_since_epoch + TOD_Control *the_tod, + Watchdog_Interval seconds_since_epoch ) { - rtems_interval ticks_until_next_second; + Watchdog_Interval ticks_until_next_second; _Thread_Disable_dispatch(); _TOD_Deactivate(); @@ -109,14 +109,14 @@ void _TOD_Set( * the_tod - pointer to a time and date structure * * Output parameters: - * RTEMS_SUCCESSFUL - if the date, time, and tick are valid - * RTEMS_INVALID_CLOCK - if the the_tod is invalid + * TRUE - if the date, time, and tick are valid + * FALSE - if the the_tod is invalid * * NOTE: This routine only works for leap-years through 2099. */ -rtems_status_code _TOD_Validate( - rtems_time_of_day *the_tod +boolean _TOD_Validate( + TOD_Control *the_tod ) { unsigned32 days_in_month; @@ -129,7 +129,7 @@ rtems_status_code _TOD_Validate( (the_tod->month > TOD_MONTHS_PER_YEAR) || (the_tod->year < TOD_BASE_YEAR) || (the_tod->day == 0) ) - return RTEMS_INVALID_CLOCK; + return FALSE; if ( (the_tod->year % 4) == 0 ) days_in_month = _TOD_Days_per_month[ 1 ][ the_tod->month ]; @@ -137,9 +137,9 @@ rtems_status_code _TOD_Validate( days_in_month = _TOD_Days_per_month[ 0 ][ the_tod->month ]; if ( the_tod->day > days_in_month ) - return RTEMS_INVALID_CLOCK; + return FALSE; - return RTEMS_SUCCESSFUL; + return TRUE; } /*PAGE @@ -157,7 +157,7 @@ rtems_status_code _TOD_Validate( */ unsigned32 _TOD_To_seconds( - rtems_time_of_day *the_tod + TOD_Control *the_tod ) { unsigned32 time; diff --git a/c/src/exec/score/src/heap.c b/c/src/exec/score/src/heap.c index eb1c5d769e..b16cfde9de 100644 --- a/c/src/exec/score/src/heap.c +++ b/c/src/exec/score/src/heap.c @@ -14,7 +14,7 @@ #include <rtems/system.h> -#include <rtems/heap.h> +#include <rtems/core/heap.h> #include <rtems/sysstate.h> /*PAGE @@ -30,7 +30,7 @@ * page_size - allocatable unit of memory * * Output parameters: - * returns - maximum memory available if RTEMS_SUCCESSFUL + * returns - maximum memory available if successfully initialized * 0 - otherwise * * This is what a heap looks like in memory immediately diff --git a/c/src/exec/score/src/interr.c b/c/src/exec/score/src/interr.c new file mode 100644 index 0000000000..3eb2bc1746 --- /dev/null +++ b/c/src/exec/score/src/interr.c @@ -0,0 +1,61 @@ +/* + * Internal Error Handler + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include <rtems/system.h> +#include <rtems/core/interr.h> +#include <rtems/sysstate.h> +#include <rtems/core/userext.h> + +/*PAGE + * + * _Internal_error_Occurred + * + * This routine will invoke the fatal error handler supplied by the user + * followed by the the default one provided by the executive. The default + * error handler assumes no hardware is present to help inform the user + * of the problem. Halt stores the error code in a known register, + * disables interrupts, and halts the CPU. If the CPU does not have a + * halt instruction, it will loop to itself. + * + * Input parameters: + * the_source - what subsystem the error originated in + * is_internal - if the error was internally generated + * the_error - fatal error status code + * + * Output parameters: + * As much information as possible is stored in a CPU dependent fashion. + * See the CPU dependent code for more information. + * + * NOTE: The the_error is not necessarily a directive status code. + */ + +void volatile _Internal_error_Occurred( + Internal_errors_Source the_source, + boolean is_internal, + unsigned32 the_error +) +{ + + Internal_errors_What_happened.the_source = the_source; + Internal_errors_What_happened.is_internal = is_internal; + Internal_errors_What_happened.the_error = the_error; + + _User_extensions_Fatal( the_source, is_internal, the_error ); + + _System_state_Set( SYSTEM_STATE_FAILED ); + + _CPU_Fatal_halt( the_error ); + + /* will not return from this routine */ +} diff --git a/c/src/exec/score/src/isr.c b/c/src/exec/score/src/isr.c new file mode 100644 index 0000000000..b87bf9f249 --- /dev/null +++ b/c/src/exec/score/src/isr.c @@ -0,0 +1,60 @@ +/* + * ISR Handler + * + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * This material may be reproduced by or for the U.S. Government pursuant + * to the copyright license under the clause at DFARS 252.227-7013. This + * notice must appear in all copies of this file and its derivatives. + * + * $Id$ + */ + +#include <rtems/system.h> +#include <rtems/core/isr.h> +#include <rtems/core/stack.h> +#include <rtems/core/interr.h> +#include <rtems/core/wkspace.h> + +/* _ISR_Handler_initialization + * + * This routine initializes the ISR handler. + * + * Input parameters: NONE + * + * Output parameters: NONE + */ + +void _ISR_Handler_initialization( void ) +{ + _ISR_Signals_to_thread_executing = FALSE; + + _ISR_Nest_level = 0; + +#if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE ) + + if ( _CPU_Table.interrupt_stack_size < STACK_MINIMUM_SIZE ) + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL + ); + + _CPU_Interrupt_stack_low = + _Workspace_Allocate_or_fatal_error( _CPU_Table.interrupt_stack_size ); + + _CPU_Interrupt_stack_high = _Addresses_Add_offset( + _CPU_Interrupt_stack_low, + _CPU_Table.interrupt_stack_size + ); + +#endif + +#if ( CPU_HAS_HARDWARE_INTERRUPT_STACK == TRUE ) + _CPU_Install_interrupt_stack(); +#endif + +} diff --git a/c/src/exec/score/src/mpci.c b/c/src/exec/score/src/mpci.c index 26c27ae733..ee72d6c396 100644 --- a/c/src/exec/score/src/mpci.c +++ b/c/src/exec/score/src/mpci.c @@ -14,16 +14,20 @@ */ #include <rtems/system.h> -#include <rtems/config.h> -#include <rtems/cpu.h> -#include <rtems/fatal.h> -#include <rtems/mpci.h> -#include <rtems/mppkt.h> -#include <rtems/states.h> -#include <rtems/thread.h> -#include <rtems/threadq.h> -#include <rtems/tqdata.h> -#include <rtems/watchdog.h> +#include <rtems/core/cpu.h> +#include <rtems/core/interr.h> +#include <rtems/core/mpci.h> +#include <rtems/core/mppkt.h> +#include <rtems/core/states.h> +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/tqdata.h> +#include <rtems/core/watchdog.h> +#include <rtems/sysstate.h> + +#include <rtems/core/coresem.h> + +#include <rtems/rtems/status.h> /* XXX for TIMEOUT */ /*PAGE * @@ -32,14 +36,38 @@ * This subprogram performs the initialization necessary for this handler. */ -void _MPCI_Handler_initialization ( void ) +void _MPCI_Handler_initialization( + MPCI_Control *users_mpci_table +) { + CORE_semaphore_Attributes attributes; + + if ( _System_state_Is_multiprocessing && !users_mpci_table ) + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_NO_MPCI + ); + + _MPCI_table = users_mpci_table; + + attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; + + _CORE_semaphore_Initialize( + &_MPCI_Semaphore, + OBJECTS_NO_CLASS, /* free floating semaphore */ + &attributes, /* the_semaphore_attributes */ + 0, /* initial_value */ + NULL /* proxy_extract_callout */ + ); + _Thread_queue_Initialize( &_MPCI_Remote_blocked_threads, OBJECTS_NO_CLASS, THREAD_QUEUE_DISCIPLINE_FIFO, STATES_WAITING_FOR_RPC_REPLY, - NULL + NULL, + RTEMS_TIMEOUT ); } @@ -53,11 +81,24 @@ void _MPCI_Handler_initialization ( void ) void _MPCI_Initialization ( void ) { - (*_Configuration_MPCI_table->initialization)( - _Configuration_Table, - &_CPU_Table, - _Configuration_MP_table - ); + (*_MPCI_table->initialization)(); +} + +/*PAGE + * + * _MPCI_Register_packet_processor + * + * This routine registers the MPCI packet processor for the + * designated object class. + */ + +void _MPCI_Register_packet_processor( + Objects_Classes the_class, + MPCI_Packet_processor the_packet_processor + +) +{ + _MPCI_Packet_processors[ the_class ] = the_packet_processor; } /*PAGE @@ -68,14 +109,18 @@ void _MPCI_Initialization ( void ) * MPCI get packet callout. */ -rtems_packet_prefix *_MPCI_Get_packet ( void ) +MP_packet_Prefix *_MPCI_Get_packet ( void ) { - rtems_packet_prefix *the_packet; + MP_packet_Prefix *the_packet; - (*_Configuration_MPCI_table->get_packet)( &the_packet ); + (*_MPCI_table->get_packet)( &the_packet ); if ( the_packet == NULL ) - rtems_fatal_error_occurred( RTEMS_UNSATISFIED ); + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_OUT_OF_PACKETS + ); /* * Put in a default timeout that will be used for @@ -96,10 +141,10 @@ rtems_packet_prefix *_MPCI_Get_packet ( void ) */ void _MPCI_Return_packet ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ) { - (*_Configuration_MPCI_table->return_packet)( the_packet ); + (*_MPCI_table->return_packet)( the_packet ); } /*PAGE @@ -112,15 +157,15 @@ void _MPCI_Return_packet ( void _MPCI_Send_process_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ) { the_packet->source_tid = _Thread_Executing->Object.id; the_packet->to_convert = - ( the_packet->to_convert - sizeof(rtems_packet_prefix) ) / + ( the_packet->to_convert - sizeof(MP_packet_Prefix) ) / sizeof(unsigned32); - (*_Configuration_MPCI_table->send_packet)( destination, the_packet ); + (*_MPCI_table->send_packet)( destination, the_packet ); } /*PAGE @@ -131,16 +176,16 @@ void _MPCI_Send_process_packet ( * MPCI send callout. */ -rtems_status_code _MPCI_Send_request_packet ( +unsigned32 _MPCI_Send_request_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet, + MP_packet_Prefix *the_packet, States_Control extra_state ) { the_packet->source_tid = _Thread_Executing->Object.id; the_packet->source_priority = _Thread_Executing->current_priority; the_packet->to_convert = - ( the_packet->to_convert - sizeof(rtems_packet_prefix) ) / + ( the_packet->to_convert - sizeof(MP_packet_Prefix) ) / sizeof(unsigned32); _Thread_Executing->Wait.id = the_packet->id; @@ -149,7 +194,7 @@ rtems_status_code _MPCI_Send_request_packet ( _Thread_Disable_dispatch(); - (*_Configuration_MPCI_table->send_packet)( destination, the_packet ); + (*_MPCI_table->send_packet)( destination, the_packet ); _MPCI_Remote_blocked_threads.sync = TRUE; @@ -158,7 +203,7 @@ rtems_status_code _MPCI_Send_request_packet ( */ if (the_packet->timeout == MPCI_DEFAULT_TIMEOUT) - the_packet->timeout = _Configuration_MPCI_table->default_timeout; + the_packet->timeout = _MPCI_table->default_timeout; _Thread_queue_Enqueue( &_MPCI_Remote_blocked_threads, the_packet->timeout ); @@ -180,12 +225,12 @@ rtems_status_code _MPCI_Send_request_packet ( void _MPCI_Send_response_packet ( unsigned32 destination, - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ) { the_packet->source_tid = _Thread_Executing->Object.id; - (*_Configuration_MPCI_table->send_packet)( destination, the_packet ); + (*_MPCI_table->send_packet)( destination, the_packet ); } /*PAGE @@ -196,11 +241,11 @@ void _MPCI_Send_response_packet ( * MPCI receive callout. */ -rtems_packet_prefix *_MPCI_Receive_packet ( void ) +MP_packet_Prefix *_MPCI_Receive_packet ( void ) { - rtems_packet_prefix *the_packet; + MP_packet_Prefix *the_packet; - (*_Configuration_MPCI_table->receive_packet)( &the_packet ); + (*_MPCI_table->receive_packet)( &the_packet ); return the_packet; } @@ -214,7 +259,7 @@ rtems_packet_prefix *_MPCI_Receive_packet ( void ) */ Thread_Control *_MPCI_Process_response ( - rtems_packet_prefix *the_packet + MP_packet_Prefix *the_packet ) { Thread_Control *the_thread; @@ -236,4 +281,66 @@ Thread_Control *_MPCI_Process_response ( return the_thread; } +/*PAGE + * + * _MPCI_Receive_server + * + */ + +void _MPCI_Receive_server( void ) +{ + + MP_packet_Prefix *the_packet; + MPCI_Packet_processor the_function; + Thread_Control *executing; + + executing = _Thread_Executing; + _MPCI_Receive_server_tcb = executing; + + for ( ; ; ) { + + executing->receive_packet = NULL; + + _Thread_Disable_dispatch(); + _CORE_semaphore_Seize( &_MPCI_Semaphore, 0, TRUE, WATCHDOG_NO_TIMEOUT ); + _Thread_Enable_dispatch(); + + for ( ; ; ) { + the_packet = _MPCI_Receive_packet(); + + if ( !the_packet ) + break; + + executing->receive_packet = the_packet; + + if ( !_Mp_packet_Is_valid_packet_class ( the_packet->the_class ) ) + break; + + the_function = _MPCI_Packet_processors[ the_packet->the_class ]; + + if ( !the_function ) + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_BAD_PACKET + ); + + (*the_function)( the_packet ); + } + } +} + +/*PAGE + * + * _MPCI_Announce + * + */ + +void _MPCI_Announce ( void ) +{ + _Thread_Disable_dispatch(); + (void) _CORE_semaphore_Surrender( &_MPCI_Semaphore, 0, 0 ); + _Thread_Enable_dispatch(); +} + /* end of file */ diff --git a/c/src/exec/score/src/object.c b/c/src/exec/score/src/object.c index b274579736..7ff6aa5204 100644 --- a/c/src/exec/score/src/object.c +++ b/c/src/exec/score/src/object.c @@ -14,12 +14,12 @@ */ #include <rtems/system.h> -#include <rtems/chain.h> -#include <rtems/config.h> -#include <rtems/object.h> +#include <rtems/core/chain.h> +#include <rtems/core/object.h> #include <rtems/objectmp.h> -#include <rtems/thread.h> -#include <rtems/wkspace.h> +#include <rtems/core/thread.h> +#include <rtems/core/wkspace.h> +#include <rtems/sysstate.h> /*PAGE * @@ -29,6 +29,7 @@ * * Input parameters: * node - local node + * maximum_nodes - number of nodes in the system * maximum_global_objects - number of configured global objects * * Output parameters: NONE @@ -36,12 +37,25 @@ void _Objects_Handler_initialization( unsigned32 node, + unsigned32 maximum_nodes, unsigned32 maximum_global_objects ) { - _Objects_Local_node = node; + if ( node < 1 || node > maximum_nodes ) + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_INVALID_NODE + ); + + _Objects_Local_node = node; + _Objects_Maximum_nodes = maximum_nodes; - _Objects_MP_Handler_initialization( maximum_global_objects ); + _Objects_MP_Handler_initialization( + node, + maximum_nodes, + maximum_global_objects + ); } /*PAGE @@ -166,15 +180,13 @@ void _Objects_Initialize_information( * Take care of multiprocessing */ - if ( supports_global == TRUE && _Configuration_Is_multiprocessing() ) { + if ( supports_global == TRUE && _System_state_Is_multiprocessing ) { information->global_table = _Workspace_Allocate_or_fatal_error( - (_Configuration_MP_table->maximum_nodes + 1) * sizeof(Chain_Control) + (_Objects_Maximum_nodes + 1) * sizeof(Chain_Control) ); - for ( index=1; - index <= _Configuration_MP_table->maximum_nodes ; - index++ ) + for ( index=1; index <= _Objects_Maximum_nodes ; index++ ) _Chain_Initialize_empty( &information->global_table[ index ] ); } else @@ -308,12 +320,12 @@ boolean _Objects_Compare_name_raw( * id - address of return ID * * Output parameters: - * obj_id - object id - * RTEMS_SUCCESSFUL - if successful - * error code - if unsuccessful + * id - object id + * OBJECTS_SUCCESSFUL - if successful + * error code - if unsuccessful */ -rtems_status_code _Objects_Name_to_id( +Objects_Name_to_id_errors _Objects_Name_to_id( Objects_Information *information, Objects_Name name, unsigned32 node, @@ -328,12 +340,12 @@ rtems_status_code _Objects_Name_to_id( Objects_Name_comparators compare_them; if ( name == 0 ) - return( RTEMS_INVALID_NAME ); + return OBJECTS_INVALID_NAME; search_local_node = FALSE; if ( information->maximum != 0 && - (node == RTEMS_SEARCH_ALL_NODES || node == RTEMS_SEARCH_LOCAL_NODE || + (node == OBJECTS_SEARCH_ALL_NODES || node == OBJECTS_SEARCH_LOCAL_NODE || _Objects_Is_local_node( node ) ) ) search_local_node = TRUE; @@ -354,13 +366,13 @@ rtems_status_code _Objects_Name_to_id( if ( (*compare_them)( name, the_object->name, name_length ) ) { *id = the_object->id; - return( RTEMS_SUCCESSFUL ); + return OBJECTS_SUCCESSFUL; } } } - if ( _Objects_Is_local_node( node ) || node == RTEMS_SEARCH_LOCAL_NODE ) - return( RTEMS_INVALID_NAME ); + if ( _Objects_Is_local_node( node ) || node == OBJECTS_SEARCH_LOCAL_NODE ) + return OBJECTS_INVALID_NAME; return ( _Objects_MP_Global_name_search( information, name, node, id ) ); } @@ -449,14 +461,14 @@ _Objects_Get_next( Objects_Control *object; Objects_Id next_id; - if (rtems_get_index(id) == RTEMS_OBJECT_ID_INITIAL_INDEX) + if (_Objects_Get_index(id) == OBJECTS_ID_INITIAL_INDEX) next_id = information->minimum_id; else next_id = id; do { /* walked off end of list? */ - if (rtems_get_index(next_id) > information->maximum) + if (_Objects_Get_index(next_id) > information->maximum) { *location_p = OBJECTS_ERROR; goto final; @@ -473,7 +485,7 @@ _Objects_Get_next( return object; final: - *next_id_p = RTEMS_OBJECT_ID_FINAL; + *next_id_p = OBJECTS_ID_FINAL; return 0; } @@ -490,7 +502,7 @@ Objects_Information *_Objects_Get_information( { Objects_Classes the_class; - the_class = rtems_get_class( id ); + the_class = _Objects_Get_class( id ); if ( !_Objects_Is_class_valid( the_class ) ) return NULL; diff --git a/c/src/exec/score/src/objectmp.c b/c/src/exec/score/src/objectmp.c index 9752aadbc6..a7c1eff58c 100644 --- a/c/src/exec/score/src/objectmp.c +++ b/c/src/exec/score/src/objectmp.c @@ -14,9 +14,10 @@ */ #include <rtems/system.h> -#include <rtems/object.h> -#include <rtems/wkspace.h> -#include <rtems/config.h> +#include <rtems/core/interr.h> +#include <rtems/core/object.h> +#include <rtems/core/wkspace.h> +#include <rtems/rtems/support.h> /*PAGE * @@ -25,9 +26,12 @@ */ void _Objects_MP_Handler_initialization ( - unsigned32 maximum_global_objects + unsigned32 node, + unsigned32 maximum_nodes, + unsigned32 maximum_global_objects ) { + _Objects_MP_Maximum_global_objects = maximum_global_objects; if ( maximum_global_objects == 0 ) { _Chain_Initialize_empty( &_Objects_MP_Inactive_global_objects ); @@ -62,7 +66,7 @@ void _Objects_MP_Open ( the_global_object->name = the_name; _Chain_Prepend( - &information->global_table[ rtems_get_node( the_id ) ], + &information->global_table[ _Objects_Get_node( the_id ) ], &the_global_object->Object.Node ); @@ -89,7 +93,11 @@ boolean _Objects_MP_Allocate_and_open ( if ( is_fatal_error == FALSE ) return FALSE; - rtems_fatal_error_occurred( RTEMS_TOO_MANY ); + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS + ); } @@ -113,7 +121,7 @@ void _Objects_MP_Close ( Chain_Node *the_node; Objects_MP_Control *the_object; - the_chain = &information->global_table[ rtems_get_node( the_id ) ]; + the_chain = &information->global_table[ _Objects_Get_node( the_id ) ]; for ( the_node = the_chain->first ; !_Chain_Is_tail( the_chain, the_node ) ; @@ -132,9 +140,11 @@ void _Objects_MP_Close ( } - rtems_fatal_error_occurred( RTEMS_INVALID_ID ); - - + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_INVALID_GLOBAL_ID + ); } /*PAGE @@ -143,7 +153,7 @@ void _Objects_MP_Close ( * */ -rtems_status_code _Objects_MP_Global_name_search ( +Objects_Name_to_id_errors _Objects_MP_Global_name_search ( Objects_Information *information, Objects_Name the_name, unsigned32 nodes_to_search, @@ -158,17 +168,16 @@ rtems_status_code _Objects_MP_Global_name_search ( Objects_MP_Control *the_object; unsigned32 name_to_use = *(unsigned32 *)the_name; /* XXX variable */ - - if ( nodes_to_search > _Configuration_MP_table->maximum_nodes ) - return ( RTEMS_INVALID_NODE ); + if ( nodes_to_search > _Objects_Maximum_nodes ) + return OBJECTS_INVALID_NODE; if ( information->global_table == NULL ) - return ( RTEMS_INVALID_NAME ); + return OBJECTS_INVALID_NAME; - if ( nodes_to_search == RTEMS_SEARCH_ALL_NODES || - nodes_to_search == RTEMS_SEARCH_OTHER_NODES ) { + if ( nodes_to_search == OBJECTS_SEARCH_ALL_NODES || + nodes_to_search == OBJECTS_SEARCH_OTHER_NODES ) { low_node = 1; - high_node = _Configuration_MP_table->maximum_nodes; + high_node = _Objects_Maximum_nodes; } else { low_node = high_node = nodes_to_search; @@ -195,14 +204,14 @@ rtems_status_code _Objects_MP_Global_name_search ( if ( the_object->name == name_to_use ) { *the_id = the_object->Object.id; _Thread_Enable_dispatch(); - return ( RTEMS_SUCCESSFUL ); + return OBJECTS_SUCCESSFUL; } } } } _Thread_Enable_dispatch(); - return ( RTEMS_INVALID_NAME ); + return OBJECTS_INVALID_NAME; } /*PAGE @@ -223,7 +232,7 @@ void _Objects_MP_Is_remote ( Chain_Node *the_node; Objects_MP_Control *the_global_object; - node = rtems_get_node( the_id ); + node = _Objects_Get_node( the_id ); /* * NOTE: The local node was search (if necessary) by @@ -235,7 +244,7 @@ void _Objects_MP_Is_remote ( if ( node == 0 || _Objects_Is_local_node( node ) || - node > _Configuration_MP_table->maximum_nodes || + node > _Objects_Maximum_nodes || information->global_table == NULL ) { *location = OBJECTS_ERROR; diff --git a/c/src/exec/score/src/thread.c b/c/src/exec/score/src/thread.c index dfc5324cb8..d507e8e075 100644 --- a/c/src/exec/score/src/thread.c +++ b/c/src/exec/score/src/thread.c @@ -14,19 +14,17 @@ */ #include <rtems/system.h> -#include <rtems/config.h> -#include <rtems/context.h> -#include <rtems/fatal.h> -#include <rtems/init.h> -#include <rtems/intthrd.h> -#include <rtems/isr.h> -#include <rtems/modes.h> -#include <rtems/object.h> -#include <rtems/priority.h> -#include <rtems/states.h> -#include <rtems/thread.h> -#include <rtems/userext.h> -#include <rtems/wkspace.h> +#include <rtems/core/context.h> +#include <rtems/core/interr.h> +#include <rtems/core/intthrd.h> +#include <rtems/core/isr.h> +#include <rtems/core/object.h> +#include <rtems/core/priority.h> +#include <rtems/core/states.h> +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/userext.h> +#include <rtems/core/wkspace.h> /*PAGE * @@ -43,6 +41,7 @@ void _Thread_Handler_initialization( unsigned32 ticks_per_timeslice, + unsigned32 maximum_extensions, unsigned32 maximum_proxies ) { @@ -53,14 +52,16 @@ void _Thread_Handler_initialization( _Thread_Heir = NULL; _Thread_Allocated_fp = NULL; + _Thread_Maximum_extensions = maximum_extensions; + _Thread_Ticks_remaining_in_timeslice = ticks_per_timeslice; _Thread_Ticks_per_timeslice = ticks_per_timeslice; _Thread_Ready_chain = _Workspace_Allocate_or_fatal_error( - (RTEMS_MAXIMUM_PRIORITY + 1) * sizeof(Chain_Control) + (PRIORITY_MAXIMUM + 1) * sizeof(Chain_Control) ); - for ( index=0; index <= RTEMS_MAXIMUM_PRIORITY ; index++ ) + for ( index=0; index <= PRIORITY_MAXIMUM ; index++ ) _Chain_Initialize_empty( &_Thread_Ready_chain[ index ] ); _Thread_MP_Handler_initialization( maximum_proxies ); @@ -145,8 +146,6 @@ void _Thread_Dispatch( void ) Thread_Control *executing; Thread_Control *heir; ISR_Level level; - rtems_signal_set signal_set; - Modes_Control previous_mode; executing = _Thread_Executing; _ISR_Disable( level ); @@ -157,7 +156,7 @@ void _Thread_Dispatch( void ) _Thread_Executing = heir; _ISR_Enable( level ); - _User_extensions_Task_switch( executing, heir ); + _User_extensions_Thread_switch( executing, heir ); _Thread_Ticks_remaining_in_timeslice = _Thread_Ticks_per_timeslice; @@ -194,30 +193,16 @@ void _Thread_Dispatch( void ) _Context_Switch( &executing->Registers, &heir->Registers ); executing = _Thread_Executing; + _ISR_Disable( level ); } _Thread_Dispatch_disable_level = 0; - if ( _ASR_Are_signals_pending( &executing->RTEMS_API->Signal ) ) { - signal_set = executing->RTEMS_API->Signal.signals_posted; - executing->RTEMS_API->Signal.signals_posted = 0; - _ISR_Enable( level ); - - executing->RTEMS_API->Signal.nest_level += 1; - if (_Thread_Change_mode( executing->RTEMS_API->Signal.mode_set, - RTEMS_ALL_MODE_MASKS, &previous_mode )) - _Thread_Dispatch(); - - (*executing->RTEMS_API->Signal.handler)( signal_set ); + _ISR_Enable( level ); - executing->RTEMS_API->Signal.nest_level -= 1; - if (_Thread_Change_mode( previous_mode, - RTEMS_ALL_MODE_MASKS, &previous_mode )) - _Thread_Dispatch(); - } - else - _ISR_Enable( level ); + _User_extensions_Thread_post_switch( executing ); + } /*PAGE @@ -234,7 +219,9 @@ boolean _Thread_Initialize( unsigned32 stack_size, /* insure it is >= min */ boolean is_fp, /* TRUE if thread uses FP */ Priority_Control priority, - Modes_Control mode, + boolean is_preemptible, + boolean is_timeslice, + unsigned32 isr_level, Objects_Name name ) @@ -242,13 +229,14 @@ boolean _Thread_Initialize( unsigned32 actual_stack_size; void *stack; void *fp_area; + void *extensions_area; /* * Allocate and Initialize the stack for this thread. */ if ( !_Stack_Is_enough( stack_size ) ) - actual_stack_size = RTEMS_MINIMUM_STACK_SIZE; + actual_stack_size = STACK_MINIMUM_SIZE; else actual_stack_size = stack_size; @@ -279,7 +267,8 @@ boolean _Thread_Initialize( fp_area = _Workspace_Allocate( CONTEXT_FP_SIZE ); if ( !fp_area ) { - (void) _Workspace_Free( stack ); + if ( the_thread->Start.stack ) + (void) _Workspace_Free( the_thread->Start.stack ); return FALSE; } fp_area = _Context_Fp_start( fp_area, 0 ); @@ -290,45 +279,42 @@ boolean _Thread_Initialize( the_thread->fp_context = fp_area; the_thread->Start.fp_context = fp_area; -/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ + /* - * Allocate and initialize the RTEMS API specific information + * Allocate the floating point area for this thread */ - - the_thread->RTEMS_API = _Workspace_Allocate( sizeof( RTEMS_API_Control ) ); - - if ( !the_thread->RTEMS_API ) { -/* XXX when in task_create - _RTEMS_tasks_Free( the_thread ); - _Objects_MP_Free_global_object( the_global_object ); - - _Thread_Enable_dispatch(); - return( RTEMS_UNSATISFIED ); -*/ - (void) _Workspace_Free( stack ); - (void) _Workspace_Free( fp_area ); - return FALSE; - - } - - the_thread->RTEMS_API->is_global = FALSE; - the_thread->RTEMS_API->pending_events = EVENT_SETS_NONE_PENDING; - _ASR_Initialize( &the_thread->RTEMS_API->Signal ); - /* XXX should not be here .... */ - -/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ + if ( _Thread_Maximum_extensions ) { + extensions_area = _Workspace_Allocate( + (_Thread_Maximum_extensions + 1) * sizeof( void * ) + ); + + if ( !extensions_area ) { + if ( fp_area ) + (void) _Workspace_Free( fp_area ); + + if ( the_thread->Start.stack ) + (void) _Workspace_Free( the_thread->Start.stack ); + + return FALSE; + } + } else + extensions_area = NULL; + + the_thread->extensions = extensions_area; /* * General initialization */ + the_thread->Start.is_preemptible = is_preemptible; + the_thread->Start.is_timeslice = is_timeslice; + the_thread->Start.isr_level = isr_level; + the_thread->current_state = STATES_DORMANT; - the_thread->current_modes = mode; the_thread->resource_count = 0; the_thread->real_priority = priority; the_thread->Start.initial_priority = priority; - the_thread->Start.initial_modes = mode; _Thread_Set_priority( the_thread, priority ); @@ -342,10 +328,22 @@ boolean _Thread_Initialize( * Invoke create extensions */ - _User_extensions_Task_create( the_thread ); - /* XXX if this fails ... */ + if ( !_User_extensions_Thread_create( the_thread ) ) { + + if ( extensions_area ) + (void) _Workspace_Free( extensions_area ); + + if ( fp_area ) + (void) _Workspace_Free( fp_area ); + + if ( the_thread->Start.stack ) + (void) _Workspace_Free( the_thread->Start.stack ); + + return FALSE; + } return TRUE; + } /* @@ -376,7 +374,7 @@ boolean _Thread_Start( _Thread_Ready( the_thread ); - _User_extensions_Task_start( the_thread ); + _User_extensions_Thread_start( the_thread ); return TRUE; } @@ -403,7 +401,8 @@ boolean _Thread_Restart( _Thread_Set_transient( the_thread ); the_thread->resource_count = 0; - the_thread->current_modes = the_thread->Start.initial_modes; + the_thread->is_preemptible = the_thread->Start.is_preemptible; + the_thread->is_timeslice = the_thread->Start.is_timeslice; the_thread->Start.pointer_argument = pointer_argument; the_thread->Start.numeric_argument = numeric_argument; @@ -423,7 +422,7 @@ boolean _Thread_Restart( _Thread_Ready( the_thread ); - _User_extensions_Task_restart( the_thread ); + _User_extensions_Thread_restart( the_thread ); if ( _Thread_Is_executing ( the_thread ) ) _Thread_Restart_self(); @@ -457,7 +456,7 @@ void _Thread_Close( (void) _Watchdog_Remove( &the_thread->Timer ); } - _User_extensions_Task_delete( the_thread ); + _User_extensions_Thread_delete( the_thread ); #if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) if ( _Thread_Is_allocated_fp( the_thread ) ) @@ -469,6 +468,9 @@ void _Thread_Close( if ( the_thread->Start.stack ) (void) _Workspace_Free( the_thread->Start.stack ); + + if ( the_thread->extensions ) + (void) _Workspace_Free( the_thread->extensions ); } /*PAGE @@ -512,8 +514,7 @@ void _Thread_Ready( heir = _Thread_Heir; - if ( !_Thread_Is_executing( heir ) && - _Modes_Is_preempt( _Thread_Executing->current_modes ) ) + if ( !_Thread_Is_executing( heir ) && _Thread_Executing->is_preemptible ) _Context_Switch_necessary = TRUE; _ISR_Enable( level ); @@ -559,7 +560,7 @@ void _Thread_Clear_state( if ( the_thread->current_priority < _Thread_Heir->current_priority ) { _Thread_Heir = the_thread; - if ( _Modes_Is_preempt( _Thread_Executing->current_modes ) || + if ( _Thread_Executing->is_preemptible || the_thread->current_priority == 0 ) _Context_Switch_necessary = TRUE; } @@ -729,9 +730,12 @@ void _Thread_Reset_timeslice( void ) void _Thread_Tickle_timeslice( void ) { - if ( ( _Modes_Is_timeslice(_Thread_Executing->current_modes) ) && - ( _States_Is_ready( _Thread_Executing->current_state ) ) && - ( --_Thread_Ticks_remaining_in_timeslice == 0 ) ) { + if ( !_Thread_Executing->is_timeslice || + !_Thread_Executing->is_preemptible || + !_States_Is_ready( _Thread_Executing->current_state ) ) + return; + + if ( --_Thread_Ticks_remaining_in_timeslice == 0 ) { _Thread_Reset_timeslice(); } } @@ -803,11 +807,14 @@ void _Thread_Load_environment( _Context_Initialize_fp( &the_thread->fp_context ); } + the_thread->is_preemptible = the_thread->Start.is_preemptible; + the_thread->is_timeslice = the_thread->Start.is_timeslice; + _Context_Initialize( &the_thread->Registers, the_thread->Start.Initial_stack.area, the_thread->Start.Initial_stack.size, - _Modes_Get_interrupt_level( the_thread->Start.initial_modes ), + the_thread->Start.isr_level, _Thread_Handler ); @@ -838,7 +845,7 @@ void _Thread_Handler( void ) * disabled until all 'begin' extensions complete. */ - _User_extensions_Task_begin( executing ); + _User_extensions_Thread_begin( executing ); /* * At this point, the dispatch disable level BETTER be 1. @@ -846,7 +853,7 @@ void _Thread_Handler( void ) _Thread_Enable_dispatch(); - switch ( executing->Start.prototype ) { + switch ( executing->Start.prototype ) { case THREAD_START_NUMERIC: (*executing->Start.entry_point)( executing->Start.numeric_argument ); break; @@ -867,9 +874,13 @@ void _Thread_Handler( void ) break; } - _User_extensions_Task_exitted( executing ); + _User_extensions_Thread_exitted( executing ); - rtems_fatal_error_occurred( RTEMS_TASK_EXITTED ); + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_THREAD_EXITTED + ); } /*PAGE @@ -953,7 +964,7 @@ void _Thread_Change_priority( _Thread_Calculate_heir(); if ( !_Thread_Is_executing_also_the_heir() && - _Modes_Is_preempt(_Thread_Executing->current_modes) ) + _Thread_Executing->is_preemptible ) _Context_Switch_necessary = TRUE; _ISR_Enable( level ); @@ -986,60 +997,24 @@ void _Thread_Set_priority( /*PAGE * - * _Thread_Change_mode - * - * This routine enables and disables several modes of - * execution for the requesting thread. - * - * Input parameters: - * mode - new mode - * mask - mask - * old_mode_set - address of previous mode + * _Thread_Evaluate_mode * - * Output: - * *old_mode_set - previous mode - * returns TRUE if scheduling necessary - * - * INTERRUPT LATENCY: - * only one case + * XXX */ -boolean _Thread_Change_mode( - Modes_Control new_mode_set, - Modes_Control mask, - Modes_Control *old_mode_set -) +boolean _Thread_Evaluate_mode( void ) { - Modes_Control changed; - Modes_Control threads_new_mode_set; - Thread_Control *executing; - boolean need_dispatch; - - executing = _Thread_Executing; - *old_mode_set = executing->current_modes; - - _Modes_Change( executing->current_modes, - new_mode_set, mask, &threads_new_mode_set, &changed ); + Thread_Control *executing; - _Modes_Set_interrupt_level( threads_new_mode_set ); - - if ( _Modes_Mask_changed( changed, RTEMS_ASR_MASK ) ) - _ASR_Swap_signals( &executing->RTEMS_API->Signal ); - - executing->current_modes = threads_new_mode_set; - need_dispatch = TRUE; + executing = _Thread_Executing; if ( !_States_Is_ready( executing->current_state ) || - ( !_Thread_Is_heir( executing ) && - _Modes_Is_preempt(threads_new_mode_set) ) ) - - _Context_Switch_necessary = TRUE; - - else if ( !_ASR_Are_signals_pending( &executing->RTEMS_API->Signal ) ) - - need_dispatch = FALSE; + ( !_Thread_Is_heir( executing ) && executing->is_preemptible ) ) { + _Context_Switch_necessary = TRUE; + return TRUE; + } - return need_dispatch; + return FALSE; } /*PAGE @@ -1068,7 +1043,7 @@ STATIC INLINE Thread_Control *_Thread_Get ( return( _Thread_Executing ); } - the_class = rtems_get_class( id ); + the_class = _Objects_Get_class( id ); if ( the_class > OBJECTS_CLASSES_LAST ) { *location = OBJECTS_ERROR; diff --git a/c/src/exec/score/src/threadmp.c b/c/src/exec/score/src/threadmp.c index f2b78cd8cd..fe346c0b9c 100644 --- a/c/src/exec/score/src/threadmp.c +++ b/c/src/exec/score/src/threadmp.c @@ -14,9 +14,10 @@ */ #include <rtems/system.h> -#include <rtems/priority.h> -#include <rtems/thread.h> -#include <rtems/wkspace.h> +#include <rtems/core/priority.h> +#include <rtems/core/thread.h> +#include <rtems/core/wkspace.h> +#include <rtems/core/isr.h> /*PAGE * @@ -67,7 +68,7 @@ Thread_Control *_Thread_MP_Allocate_proxy ( the_proxy = (Thread_Proxy_control *) the_thread; - _Thread_Executing->Wait.return_code = RTEMS_PROXY_BLOCKING; + _Thread_Executing->Wait.return_code = THREAD_STATUS_PROXY_BLOCKING; the_proxy->receive_packet = _Thread_MP_Receive->receive_packet; @@ -85,7 +86,11 @@ Thread_Control *_Thread_MP_Allocate_proxy ( return the_thread; } - rtems_fatal_error_occurred( RTEMS_TOO_MANY ); + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_OUT_OF_PROXIES + ); /* * NOTE: The following return insures that the compiler will diff --git a/c/src/exec/score/src/threadq.c b/c/src/exec/score/src/threadq.c index 7b4647bb7f..ec6f8cc242 100644 --- a/c/src/exec/score/src/threadq.c +++ b/c/src/exec/score/src/threadq.c @@ -14,13 +14,15 @@ */ #include <rtems/system.h> -#include <rtems/chain.h> -#include <rtems/isr.h> -#include <rtems/object.h> -#include <rtems/states.h> -#include <rtems/thread.h> -#include <rtems/threadq.h> -#include <rtems/tqdata.h> +#include <rtems/core/chain.h> +#include <rtems/core/isr.h> +#include <rtems/core/object.h> +#include <rtems/core/states.h> +#include <rtems/core/thread.h> +#include <rtems/core/threadq.h> +#include <rtems/core/tqdata.h> + +#include <rtems/rtems/status.h> /*PAGE * @@ -29,10 +31,12 @@ * This routine initializes the specified threadq. * * Input parameters: - * the_thread_queue - pointer to a threadq header - * the_class - class of the object to which this belongs - * discipline - queueing discipline - * state - state of waiting threads + * the_thread_queue - pointer to a threadq header + * the_class - class of the object to which this belongs + * discipline - queueing discipline + * state - state of waiting threads + * proxy_extract_callout - MP specific callout + * timeout_status - return on a timeout * * Output parameters: NONE */ @@ -42,15 +46,17 @@ void _Thread_queue_Initialize( Objects_Classes the_class, Thread_queue_Disciplines the_discipline, States_Control state, - Thread_queue_Extract_callout proxy_extract_callout + Thread_queue_Extract_callout proxy_extract_callout, + unsigned32 timeout_status ) { unsigned32 index; _Thread_queue_Extract_table[ the_class ] = proxy_extract_callout; - the_thread_queue->state = state; - the_thread_queue->discipline = the_discipline; + the_thread_queue->state = state; + the_thread_queue->discipline = the_discipline; + the_thread_queue->timeout_status = timeout_status; switch ( the_discipline ) { case THREAD_QUEUE_DISCIPLINE_FIFO: @@ -85,14 +91,14 @@ void _Thread_queue_Initialize( void _Thread_queue_Enqueue( Thread_queue_Control *the_thread_queue, - rtems_interval timeout + Watchdog_Interval timeout ) { Thread_Control *the_thread; the_thread = _Thread_Executing; - if ( _Thread_MP_Is_receive( the_thread ) ) + if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state ); else _Thread_Set_state( the_thread, the_thread_queue->state ); @@ -128,7 +134,7 @@ void _Thread_queue_Enqueue( * _Thread_queue_Dequeue * * This routine removes a thread from the specified threadq. If the - * threadq discipline is RTEMS_FIFO, it unblocks a thread, and cancels its + * threadq discipline is FIFO, it unblocks a thread, and cancels its * timeout timer. Priority discipline is processed elsewhere. * * Input parameters: @@ -139,7 +145,6 @@ void _Thread_queue_Enqueue( * * INTERRUPT LATENCY: * check sync - * RTEMS_FIFO */ Thread_Control *_Thread_queue_Dequeue( @@ -200,7 +205,7 @@ boolean _Thread_queue_Extract_with_proxy( if ( _States_Is_waiting_for_rpc_reply( state ) && _States_Is_locally_blocked( state ) ) { - the_class = rtems_get_class( the_thread->Wait.id ); + the_class = _Objects_Get_class( the_thread->Wait.id ); proxy_extract_callout = _Thread_queue_Extract_table[ the_class ]; @@ -252,21 +257,24 @@ void _Thread_queue_Extract( * This kernel routine flushes the given thread queue. * * Input parameters: - * the_thread_queue - pointer to threadq to be flushed + * the_thread_queue - pointer to threadq to be flushed + * remote_extract_callout - pointer to routine which extracts a remote thread + * status - status to return to the thread * * Output parameters: NONE */ void _Thread_queue_Flush( Thread_queue_Control *the_thread_queue, - Thread_queue_Flush_callout remote_extract_callout + Thread_queue_Flush_callout remote_extract_callout, + unsigned32 status ) { Thread_Control *the_thread; while ( (the_thread = _Thread_queue_Dequeue( the_thread_queue )) ) { if ( _Objects_Is_local_id( the_thread->Object.id ) ) - the_thread->Wait.return_code = RTEMS_OBJECT_WAS_DELETED; + the_thread->Wait.return_code = status; else ( *remote_extract_callout )( the_thread ); } @@ -334,7 +342,7 @@ void _Thread_queue_Timeout( case OBJECTS_REMOTE: /* impossible */ break; case OBJECTS_LOCAL: - the_thread->Wait.return_code = RTEMS_TIMEOUT; + the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status; _Thread_queue_Extract( the_thread->Wait.queue, the_thread ); _Thread_Unnest_dispatch(); break; @@ -362,7 +370,7 @@ void _Thread_queue_Timeout( void _Thread_queue_Enqueue_fifo ( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, - rtems_interval timeout + Watchdog_Interval timeout ) { ISR_Level level; @@ -376,7 +384,7 @@ void _Thread_queue_Enqueue_fifo ( &the_thread->Object.Node ); - if ( timeout != RTEMS_NO_TIMEOUT ) + if ( timeout != WATCHDOG_NO_TIMEOUT ) _Watchdog_Activate( &the_thread->Timer ); _ISR_Enable( level ); @@ -412,7 +420,7 @@ void _Thread_queue_Enqueue_fifo ( * * INTERRUPT LATENCY: * check sync - * RTEMS_FIFO + * FIFO */ Thread_Control *_Thread_queue_Dequeue_fifo( @@ -541,7 +549,7 @@ Thread_Control *_Thread_queue_First_fifo( void _Thread_queue_Enqueue_priority( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, - rtems_interval timeout + Watchdog_Interval timeout ) { Priority_Control search_priority; @@ -567,7 +575,7 @@ void _Thread_queue_Enqueue_priority( goto restart_reverse_search; restart_forward_search: - search_priority = RTEMS_MINIMUM_PRIORITY - 1; + search_priority = PRIORITY_MINIMUM - 1; _ISR_Disable( level ); search_thread = (Thread_Control *) header->first; while ( !_Chain_Is_tail( header, (Chain_Node *)search_thread ) ) { @@ -595,7 +603,7 @@ restart_forward_search: goto syncronize; the_thread_queue->sync = FALSE; - if ( timeout != RTEMS_NO_TIMEOUT ) + if ( timeout != WATCHDOG_NO_TIMEOUT ) _Watchdog_Activate( &the_thread->Timer ); if ( priority == search_priority ) @@ -613,7 +621,7 @@ restart_forward_search: return; restart_reverse_search: - search_priority = RTEMS_MAXIMUM_PRIORITY + 1; + search_priority = PRIORITY_MAXIMUM + 1; _ISR_Disable( level ); search_thread = (Thread_Control *) header->last; @@ -641,7 +649,7 @@ restart_reverse_search: goto syncronize; the_thread_queue->sync = FALSE; - if ( timeout != RTEMS_NO_TIMEOUT ) + if ( timeout != WATCHDOG_NO_TIMEOUT ) _Watchdog_Activate( &the_thread->Timer ); if ( priority == search_priority ) @@ -688,7 +696,7 @@ syncronize: * * _Thread_queue_Dequeue_priority * - * This routine removes a thread from the specified RTEMS_PRIORITY based + * This routine removes a thread from the specified PRIORITY based * threadq, unblocks it, and cancels its timeout timer. * * Input parameters: diff --git a/c/src/exec/score/src/tod.c b/c/src/exec/score/src/tod.c index 4689c637d7..ab464664f6 100644 --- a/c/src/exec/score/src/tod.c +++ b/c/src/exec/score/src/tod.c @@ -14,10 +14,10 @@ */ #include <rtems/system.h> -#include <rtems/object.h> -#include <rtems/thread.h> -#include <rtems/tod.h> -#include <rtems/watchdog.h> +#include <rtems/core/object.h> +#include <rtems/core/thread.h> +#include <rtems/core/tod.h> +#include <rtems/core/watchdog.h> /*PAGE * @@ -72,11 +72,11 @@ void _TOD_Handler_initialization( */ void _TOD_Set( - rtems_time_of_day *the_tod, - rtems_interval seconds_since_epoch + TOD_Control *the_tod, + Watchdog_Interval seconds_since_epoch ) { - rtems_interval ticks_until_next_second; + Watchdog_Interval ticks_until_next_second; _Thread_Disable_dispatch(); _TOD_Deactivate(); @@ -109,14 +109,14 @@ void _TOD_Set( * the_tod - pointer to a time and date structure * * Output parameters: - * RTEMS_SUCCESSFUL - if the date, time, and tick are valid - * RTEMS_INVALID_CLOCK - if the the_tod is invalid + * TRUE - if the date, time, and tick are valid + * FALSE - if the the_tod is invalid * * NOTE: This routine only works for leap-years through 2099. */ -rtems_status_code _TOD_Validate( - rtems_time_of_day *the_tod +boolean _TOD_Validate( + TOD_Control *the_tod ) { unsigned32 days_in_month; @@ -129,7 +129,7 @@ rtems_status_code _TOD_Validate( (the_tod->month > TOD_MONTHS_PER_YEAR) || (the_tod->year < TOD_BASE_YEAR) || (the_tod->day == 0) ) - return RTEMS_INVALID_CLOCK; + return FALSE; if ( (the_tod->year % 4) == 0 ) days_in_month = _TOD_Days_per_month[ 1 ][ the_tod->month ]; @@ -137,9 +137,9 @@ rtems_status_code _TOD_Validate( days_in_month = _TOD_Days_per_month[ 0 ][ the_tod->month ]; if ( the_tod->day > days_in_month ) - return RTEMS_INVALID_CLOCK; + return FALSE; - return RTEMS_SUCCESSFUL; + return TRUE; } /*PAGE @@ -157,7 +157,7 @@ rtems_status_code _TOD_Validate( */ unsigned32 _TOD_To_seconds( - rtems_time_of_day *the_tod + TOD_Control *the_tod ) { unsigned32 time; diff --git a/c/src/exec/score/src/userext.c b/c/src/exec/score/src/userext.c index 7886dbd900..6730e81219 100644 --- a/c/src/exec/score/src/userext.c +++ b/c/src/exec/score/src/userext.c @@ -15,14 +15,14 @@ */ #include <rtems/system.h> -#include <rtems/userext.h> +#include <rtems/core/userext.h> /*PAGE * - * _User_extensions_Task_create + * _User_extensions_Thread_create */ -boolean _User_extensions_Task_create ( +boolean _User_extensions_Thread_create ( Thread_Control *the_thread ) { @@ -36,8 +36,8 @@ boolean _User_extensions_Task_create ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.rtems_task_create != NULL ) { - status = (*the_extension->Callouts.rtems_task_create)( + if ( the_extension->Callouts.thread_create != NULL ) { + status = (*the_extension->Callouts.thread_create)( _Thread_Executing, the_thread ); @@ -51,10 +51,10 @@ boolean _User_extensions_Task_create ( /*PAGE * - * _User_extensions_Task_delete + * _User_extensions_Thread_delete */ -void _User_extensions_Task_delete ( +void _User_extensions_Thread_delete ( Thread_Control *the_thread ) { @@ -67,8 +67,8 @@ void _User_extensions_Task_delete ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.rtems_task_delete != NULL ) - (*the_extension->Callouts.rtems_task_delete)( + if ( the_extension->Callouts.thread_delete != NULL ) + (*the_extension->Callouts.thread_delete)( _Thread_Executing, the_thread ); @@ -77,11 +77,11 @@ void _User_extensions_Task_delete ( /*PAGE * - * _User_extensions_Task_start + * _User_extensions_Thread_start * */ -void _User_extensions_Task_start ( +void _User_extensions_Thread_start ( Thread_Control *the_thread ) { @@ -94,8 +94,8 @@ void _User_extensions_Task_start ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.rtems_task_start != NULL ) - (*the_extension->Callouts.rtems_task_start)( + if ( the_extension->Callouts.thread_start != NULL ) + (*the_extension->Callouts.thread_start)( _Thread_Executing, the_thread ); @@ -104,11 +104,11 @@ void _User_extensions_Task_start ( /*PAGE * - * _User_extensions_Task_restart + * _User_extensions_Thread_restart * */ -void _User_extensions_Task_restart ( +void _User_extensions_Thread_restart ( Thread_Control *the_thread ) { @@ -121,8 +121,8 @@ void _User_extensions_Task_restart ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.rtems_task_restart != NULL ) - (*the_extension->Callouts.rtems_task_restart)( + if ( the_extension->Callouts.thread_restart != NULL ) + (*the_extension->Callouts.thread_restart)( _Thread_Executing, the_thread ); @@ -131,11 +131,11 @@ void _User_extensions_Task_restart ( /*PAGE * - * _User_extensions_Task_begin + * _User_extensions_Thread_begin * */ -void _User_extensions_Task_begin ( +void _User_extensions_Thread_begin ( Thread_Control *executing ) { @@ -148,17 +148,17 @@ void _User_extensions_Task_begin ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.task_begin != NULL ) - (*the_extension->Callouts.task_begin)( executing ); + if ( the_extension->Callouts.thread_begin != NULL ) + (*the_extension->Callouts.thread_begin)( executing ); } } /*PAGE * - * _User_extensions_Task_exitted + * _User_extensions_Thread_exitted */ -void _User_extensions_Task_exitted ( +void _User_extensions_Thread_exitted ( Thread_Control *executing ) { @@ -171,8 +171,8 @@ void _User_extensions_Task_exitted ( the_extension = (User_extensions_Control *) the_node; - if ( the_extension->Callouts.task_exitted != NULL ) - (*the_extension->Callouts.task_exitted)( executing ); + if ( the_extension->Callouts.thread_exitted != NULL ) + (*the_extension->Callouts.thread_exitted)( executing ); } } @@ -182,7 +182,9 @@ void _User_extensions_Task_exitted ( */ void _User_extensions_Fatal ( - unsigned32 the_error + Internal_errors_Source the_source, + boolean is_internal, + unsigned32 the_error ) { Chain_Node *the_node; @@ -195,7 +197,7 @@ void _User_extensions_Fatal ( the_extension = (User_extensions_Control *) the_node; if ( the_extension->Callouts.fatal != NULL ) - (*the_extension->Callouts.fatal)( the_error ); + (*the_extension->Callouts.fatal)( the_source, is_internal, the_error ); } } diff --git a/c/src/exec/score/src/watchdog.c b/c/src/exec/score/src/watchdog.c index 3c46f9b535..53a405d725 100644 --- a/c/src/exec/score/src/watchdog.c +++ b/c/src/exec/score/src/watchdog.c @@ -14,8 +14,8 @@ */ #include <rtems/system.h> -#include <rtems/isr.h> -#include <rtems/watchdog.h> +#include <rtems/core/isr.h> +#include <rtems/core/watchdog.h> /*PAGE * @@ -104,7 +104,7 @@ Watchdog_States _Watchdog_Remove( void _Watchdog_Adjust( Chain_Control *header, Watchdog_Adjust_directions direction, - rtems_interval units + Watchdog_Interval units ) { if ( !_Chain_Is_empty( header ) ) { @@ -144,10 +144,10 @@ void _Watchdog_Insert( Watchdog_Insert_modes insert_mode ) { - ISR_Level level; - Watchdog_Control *after; - unsigned32 insert_isr_nest_level; - rtems_interval delta_interval; + ISR_Level level; + Watchdog_Control *after; + unsigned32 insert_isr_nest_level; + Watchdog_Interval delta_interval; insert_isr_nest_level = _ISR_Nest_level; diff --git a/c/src/exec/score/src/wkspace.c b/c/src/exec/score/src/wkspace.c index 97299540f8..f4be68651c 100644 --- a/c/src/exec/score/src/wkspace.c +++ b/c/src/exec/score/src/wkspace.c @@ -17,8 +17,8 @@ */ #include <rtems/system.h> -#include <rtems/wkspace.h> -#include <rtems/fatal.h> +#include <rtems/core/wkspace.h> +#include <rtems/core/interr.h> /*PAGE * @@ -35,7 +35,11 @@ void *_Workspace_Allocate_or_fatal_error( memory = _Workspace_Allocate( size ); if ( memory == NULL ) - rtems_fatal_error_occurred( RTEMS_UNSATISFIED ); + _Internal_error_Occurred( + INTERNAL_ERROR_CORE, + TRUE, + INTERNAL_ERROR_WORKSPACE_ALLOCATION + ); return memory; } |