forked from Imagelibrary/rtems
score: Simplify priority bit map implementation
The priority bit map can deal with a maximum of 256 priority values ranging from 0 to 255. Consistently use an unsigned int for computation, due to the usual integer promotion rules. Make Priority_bit_map_Word definition architecture-independent and define it to uint16_t. This was already the case for all architectures except PowerPC. Adjust the PowerPC bitmap support accordingly.
This commit is contained in:
@@ -40,8 +40,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
/** This defines the type for a priority bit map entry. */
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
/** This defines the return type for an ISR entry point. */
|
/** This defines the return type for an ISR entry point. */
|
||||||
typedef void blackfin_isr;
|
typedef void blackfin_isr;
|
||||||
|
|
||||||
|
|||||||
@@ -699,7 +699,6 @@ typedef struct {
|
|||||||
#define CPU_MAXIMUM_PROCESSORS 32
|
#define CPU_MAXIMUM_PROCESSORS 32
|
||||||
|
|
||||||
#ifndef ASM
|
#ifndef ASM
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t r[62];
|
uint32_t r[62];
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
typedef void epiphany_isr;
|
typedef void epiphany_isr;
|
||||||
typedef void ( *epiphany_isr_entry )( void );
|
typedef void ( *epiphany_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
typedef void i386_isr;
|
typedef void i386_isr;
|
||||||
typedef i386_isr ( *i386_isr_entry )( void );
|
typedef i386_isr ( *i386_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
/** This defines the type for a priority bit map entry. */
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef unsigned long CPU_Uint32ptr;
|
typedef unsigned long CPU_Uint32ptr;
|
||||||
|
|
||||||
/** This defines the type for a priority bit map entry. */
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
/** This defines the return type for an ISR entry point. */
|
/** This defines the return type for an ISR entry point. */
|
||||||
typedef void m32c_isr;
|
typedef void m32c_isr;
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
typedef void mips_isr;
|
typedef void mips_isr;
|
||||||
typedef void ( *mips_isr_entry )( void );
|
typedef void ( *mips_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
typedef void moxie_isr;
|
typedef void moxie_isr;
|
||||||
typedef void ( *moxie_isr_entry )( void );
|
typedef void ( *moxie_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
typedef void nios2_isr;
|
typedef void nios2_isr;
|
||||||
typedef void ( *nios2_isr_entry )( void );
|
typedef void ( *nios2_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
/** This defines the type for a priority bit map entry. */
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -687,7 +687,6 @@ typedef struct {
|
|||||||
|
|
||||||
#ifndef ASM
|
#ifndef ASM
|
||||||
typedef uint32_t CPU_Counter_ticks;
|
typedef uint32_t CPU_Counter_ticks;
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t r[32];
|
uint32_t r[32];
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
typedef void or1k_isr;
|
typedef void or1k_isr;
|
||||||
typedef void ( *or1k_isr_entry )( void );
|
typedef void ( *or1k_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -981,6 +981,7 @@ void _CPU_Context_Initialize(
|
|||||||
{ \
|
{ \
|
||||||
__asm__ volatile ("cntlzw %0, %1" : "=r" ((_output)), "=r" ((_value)) : \
|
__asm__ volatile ("cntlzw %0, %1" : "=r" ((_output)), "=r" ((_value)) : \
|
||||||
"1" ((_value))); \
|
"1" ((_value))); \
|
||||||
|
(_output) = (_output) - 16; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of Bitfield handler macros */
|
/* end of Bitfield handler macros */
|
||||||
@@ -992,7 +993,7 @@ void _CPU_Context_Initialize(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _CPU_Priority_Mask( _bit_number ) \
|
#define _CPU_Priority_Mask( _bit_number ) \
|
||||||
( 0x80000000 >> (_bit_number) )
|
( 0x8000u >> (_bit_number) )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This routine translates the bit numbers returned by
|
* This routine translates the bit numbers returned by
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint32_t Priority_bit_map_Word;
|
|
||||||
typedef void ppc_isr;
|
typedef void ppc_isr;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
typedef void sh_isr;
|
typedef void sh_isr;
|
||||||
typedef void ( *sh_isr_entry )( void );
|
typedef void ( *sh_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -30,15 +30,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Priority bit map type.
|
|
||||||
*
|
|
||||||
* On the SPARC, there is no bitscan instruction and no penalty associated
|
|
||||||
* for using 16-bit variables. With no overriding architectural factors,
|
|
||||||
* just using a uint16_t.
|
|
||||||
*/
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SPARC ISR handler return type.
|
* @brief SPARC ISR handler return type.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
typedef void sparc_isr;
|
typedef void sparc_isr;
|
||||||
typedef void ( *sparc_isr_entry )( void );
|
typedef void ( *sparc_isr_entry )( void );
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ extern "C" {
|
|||||||
/** Type that can store a 32-bit integer or a pointer. */
|
/** Type that can store a 32-bit integer or a pointer. */
|
||||||
typedef uintptr_t CPU_Uint32ptr;
|
typedef uintptr_t CPU_Uint32ptr;
|
||||||
|
|
||||||
/** This defines the type for a priority bit map entry. */
|
|
||||||
typedef uint16_t Priority_bit_map_Word;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
/**@{*/
|
/**@{*/
|
||||||
|
|
||||||
/*
|
typedef uint16_t Priority_bit_map_Word;
|
||||||
* The definition of the Priority_bit_map_Word type is CPU dependent.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#define _RTEMS_SCORE_PRIORITYBITMAPIMPL_H
|
#define _RTEMS_SCORE_PRIORITYBITMAPIMPL_H
|
||||||
|
|
||||||
#include <rtems/score/prioritybitmap.h>
|
#include <rtems/score/prioritybitmap.h>
|
||||||
#include <rtems/score/priority.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -65,8 +64,8 @@ extern const unsigned char _Bitfield_Leading_zeros[256];
|
|||||||
#else
|
#else
|
||||||
#define _Bitfield_Find_first_bit( _value, _bit_number ) \
|
#define _Bitfield_Find_first_bit( _value, _bit_number ) \
|
||||||
{ \
|
{ \
|
||||||
register uint32_t __value = (uint32_t) (_value); \
|
unsigned int __value = (_value); \
|
||||||
register const unsigned char *__p = _Bitfield_Leading_zeros; \
|
const unsigned char *__p = _Bitfield_Leading_zeros; \
|
||||||
\
|
\
|
||||||
if ( __value < 0x100 ) \
|
if ( __value < 0x100 ) \
|
||||||
(_bit_number) = (Priority_bit_map_Word)( __p[ __value ] + 8 ); \
|
(_bit_number) = (Priority_bit_map_Word)( __p[ __value ] + 8 ); \
|
||||||
@@ -108,22 +107,18 @@ extern const unsigned char _Bitfield_Leading_zeros[256];
|
|||||||
* This function returns the major portion of the_priority.
|
* This function returns the major portion of the_priority.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Major (
|
RTEMS_INLINE_ROUTINE unsigned int _Priority_Major( unsigned int the_priority )
|
||||||
Priority_Control the_priority
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return (Priority_bit_map_Word)( the_priority / 16 );
|
return the_priority / 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns the minor portion of the_priority.
|
* This function returns the minor portion of the_priority.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Minor (
|
RTEMS_INLINE_ROUTINE unsigned int _Priority_Minor( unsigned int the_priority )
|
||||||
Priority_Control the_priority
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return (Priority_bit_map_Word)( the_priority % 16 );
|
return the_priority % 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE )
|
#if ( CPU_USE_GENERIC_BITFIELD_CODE == TRUE )
|
||||||
@@ -134,31 +129,20 @@ RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Minor (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask (
|
RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask (
|
||||||
uint32_t bit_number
|
unsigned int bit_number
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (Priority_bit_map_Word)(0x8000u >> bit_number);
|
return (Priority_bit_map_Word)(0x8000u >> bit_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns the mask bit inverted.
|
|
||||||
*/
|
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask_invert (
|
|
||||||
uint32_t mask
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return (Priority_bit_map_Word)(~mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function translates the bit numbers returned by the bit scan
|
* This function translates the bit numbers returned by the bit scan
|
||||||
* of a priority bit field into something suitable for use as
|
* of a priority bit field into something suitable for use as
|
||||||
* a major or minor component of a priority.
|
* a major or minor component of a priority.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE uint32_t _Priority_Bits_index (
|
RTEMS_INLINE_ROUTINE unsigned int _Priority_Bits_index(
|
||||||
uint32_t bit_number
|
unsigned int bit_number
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return bit_number;
|
return bit_number;
|
||||||
@@ -196,15 +180,15 @@ RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove (
|
|||||||
bit_map->major_bit_map &= bit_map_info->block_major;
|
bit_map->major_bit_map &= bit_map_info->block_major;
|
||||||
}
|
}
|
||||||
|
|
||||||
RTEMS_INLINE_ROUTINE Priority_Control _Priority_bit_map_Get_highest(
|
RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest(
|
||||||
const Priority_bit_map_Control *bit_map
|
const Priority_bit_map_Control *bit_map
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Priority_bit_map_Word minor;
|
unsigned int minor;
|
||||||
Priority_bit_map_Word major;
|
unsigned int major;
|
||||||
|
|
||||||
/* Avoid problems with some inline ASM statements */
|
/* Avoid problems with some inline ASM statements */
|
||||||
Priority_bit_map_Word tmp;
|
unsigned int tmp;
|
||||||
|
|
||||||
tmp = bit_map->major_bit_map;
|
tmp = bit_map->major_bit_map;
|
||||||
_Bitfield_Find_first_bit( tmp, major );
|
_Bitfield_Find_first_bit( tmp, major );
|
||||||
@@ -226,11 +210,11 @@ RTEMS_INLINE_ROUTINE bool _Priority_bit_map_Is_empty(
|
|||||||
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information(
|
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information(
|
||||||
Priority_bit_map_Control *bit_map,
|
Priority_bit_map_Control *bit_map,
|
||||||
Priority_bit_map_Information *bit_map_info,
|
Priority_bit_map_Information *bit_map_info,
|
||||||
Priority_Control new_priority
|
unsigned int new_priority
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Priority_bit_map_Word major;
|
unsigned int major;
|
||||||
Priority_bit_map_Word minor;
|
unsigned int minor;
|
||||||
Priority_bit_map_Word mask;
|
Priority_bit_map_Word mask;
|
||||||
|
|
||||||
major = _Priority_Major( new_priority );
|
major = _Priority_Major( new_priority );
|
||||||
@@ -240,13 +224,11 @@ RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information(
|
|||||||
|
|
||||||
mask = _Priority_Mask( major );
|
mask = _Priority_Mask( major );
|
||||||
bit_map_info->ready_major = mask;
|
bit_map_info->ready_major = mask;
|
||||||
/* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
|
bit_map_info->block_major = (Priority_bit_map_Word) ~mask;
|
||||||
bit_map_info->block_major = (Priority_bit_map_Word)(~((uint32_t)mask));
|
|
||||||
|
|
||||||
mask = _Priority_Mask( minor );
|
mask = _Priority_Mask( minor );
|
||||||
bit_map_info->ready_minor = mask;
|
bit_map_info->ready_minor = mask;
|
||||||
/* Add _Priority_Mask_invert to non-generic bitfield then change this code. */
|
bit_map_info->block_minor = (Priority_bit_map_Word) ~mask;
|
||||||
bit_map_info->block_minor = (Priority_bit_map_Word)(~((uint32_t)mask));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|||||||
Reference in New Issue
Block a user