Merge branch 'master' of ssh://dispatch.rtems.org/data/git/rtems

This commit is contained in:
Joel Sherrill
2015-05-26 10:17:03 -05:00
7 changed files with 102 additions and 50 deletions

View File

@@ -259,8 +259,8 @@ SYM(_CPU_Context_restore):
save %sp, -CPU_MINIMUM_STACK_FRAME_SIZE, %sp
rd %psr, %o2
#if defined(RTEMS_SMP)
! On SPARC the restore path needs also a valid executing context on SMP
! to update the is executing indicator.
! On SPARC the restore path needs also a valid executing context on SMP
! to update the is executing indicator.
mov %i0, %o0
#endif
ba SYM(_CPU_Context_restore_heir)
@@ -372,8 +372,6 @@ dont_do_the_window:
* %l5 directly into the ISF below.
*/
save_isf:
/*
* Save the state of the interrupted task -- especially the global
* registers -- in the Interrupt Stack Frame. Note that the ISF
@@ -441,7 +439,7 @@ save_isf:
nop
#endif
ld [%g6 + PER_CPU_INTERRUPT_STACK_HIGH], %sp
ld [%g6 + PER_CPU_INTERRUPT_STACK_HIGH], %sp
dont_switch_stacks:
/*
@@ -460,7 +458,7 @@ dont_switch_stacks:
*/
mov %l0, %g5
and %l3, 0x0ff, %g4
and %l3, 0x0ff, %g4
subcc %g4, 0x11, %g0
bl dont_fix_pil
subcc %g4, 0x1f, %g0
@@ -474,7 +472,6 @@ dont_fix_pil:
or %g5, SPARC_PSR_PIL_MASK, %g5
pil_fixed:
wr %g5, SPARC_PSR_ET_MASK, %psr ! **** ENABLE TRAPS ****
dont_fix_pil2:
/*
* Vector to user's handler.
@@ -609,7 +606,6 @@ isr_dispatch:
ta SPARC_SWTRAP_IRQEN ! syscall (enable interrupts to same level)
! No, then clear out and return
allow_nest_again:
! Zero out ISR stack nesting prevention flag
st %g0, [%g6 + SPARC_PER_CPU_ISR_DISPATCH_DISABLE]
@@ -717,7 +713,7 @@ simple_return:
good_task_window:
mov %l0, %psr ! **** DISABLE TRAPS ****
nop; nop; nop
nop; nop; nop
! and restore condition codes.
ld [%g1 + ISF_G1_OFFSET], %g1 ! restore g1
jmp %l1 ! transfer control and

View File

@@ -8,7 +8,7 @@
#ifndef _RTEMS_ENDIAN_H
#define _RTEMS_ENDIAN_H
#include <rtems.h>
#include <rtems/score/cpu.h>
/*
* BSD-style endian declaration
@@ -95,7 +95,7 @@ static inline uint16_t htons( uint16_t _x )
static inline uint16_t rtems_uint16_from_little_endian( const uint8_t *data)
{
uint16_t value = 0;
ssize_t i = 0;
int i;
for (i = 1; i >= 0; --i) {
value = (uint16_t) ((value << 8) + data [i]);
@@ -107,7 +107,7 @@ static inline uint16_t rtems_uint16_from_little_endian( const uint8_t *data)
static inline uint32_t rtems_uint32_from_little_endian( const uint8_t *data)
{
uint32_t value = 0;
ssize_t i = 0;
int i;
for (i = 3; i >= 0; --i) {
value = (value << 8) + data [i];
@@ -119,7 +119,7 @@ static inline uint32_t rtems_uint32_from_little_endian( const uint8_t *data)
static inline uint64_t rtems_uint64_from_little_endian( const uint8_t *data)
{
uint64_t value = 0;
ssize_t i = 0;
int i;
for (i = 7; i >= 0; --i) {
value = (value << 8) + (uint64_t) data [i];
@@ -131,7 +131,7 @@ static inline uint64_t rtems_uint64_from_little_endian( const uint8_t *data)
static inline uint16_t rtems_uint16_from_big_endian( const uint8_t *data)
{
uint16_t value = 0;
size_t i = 0;
int i;
for (i = 0; i < 2; ++i) {
value = (uint16_t) ((value << 8) + data [i]);
@@ -143,7 +143,7 @@ static inline uint16_t rtems_uint16_from_big_endian( const uint8_t *data)
static inline uint32_t rtems_uint32_from_big_endian( const uint8_t *data)
{
uint32_t value = 0;
size_t i = 0;
int i;
for (i = 0; i < 4; ++i) {
value = (value << 8) + (uint32_t) data [i];
@@ -155,7 +155,7 @@ static inline uint32_t rtems_uint32_from_big_endian( const uint8_t *data)
static inline uint64_t rtems_uint64_from_big_endian( const uint8_t *data)
{
uint64_t value = 0;
size_t i = 0;
int i;
for (i = 0; i < 8; ++i) {
value = (value << 8) + (uint64_t) data [i];
@@ -166,7 +166,7 @@ static inline uint64_t rtems_uint64_from_big_endian( const uint8_t *data)
static inline void rtems_uint16_to_little_endian( uint16_t value, uint8_t *data)
{
size_t i = 0;
int i;
for (i = 0; i < 2; ++i) {
data [i] = (uint8_t) value;
@@ -176,7 +176,7 @@ static inline void rtems_uint16_to_little_endian( uint16_t value, uint8_t *data)
static inline void rtems_uint32_to_little_endian( uint32_t value, uint8_t *data)
{
size_t i = 0;
int i;
for (i = 0; i < 4; ++i) {
data [i] = (uint8_t) value;
@@ -186,7 +186,7 @@ static inline void rtems_uint32_to_little_endian( uint32_t value, uint8_t *data)
static inline void rtems_uint64_to_little_endian( uint64_t value, uint8_t *data)
{
size_t i = 0;
int i;
for (i = 0; i < 8; ++i) {
data [i] = (uint8_t) value;
@@ -196,7 +196,7 @@ static inline void rtems_uint64_to_little_endian( uint64_t value, uint8_t *data)
static inline void rtems_uint16_to_big_endian( uint16_t value, uint8_t *data)
{
ssize_t i = 0;
int i;
for (i = 1; i >= 0; --i) {
data [i] = (uint8_t) value;
@@ -206,7 +206,7 @@ static inline void rtems_uint16_to_big_endian( uint16_t value, uint8_t *data)
static inline void rtems_uint32_to_big_endian( uint32_t value, uint8_t *data)
{
ssize_t i = 0;
int i;
for (i = 3; i >= 0; --i) {
data [i] = (uint8_t) value;
@@ -216,7 +216,7 @@ static inline void rtems_uint32_to_big_endian( uint32_t value, uint8_t *data)
static inline void rtems_uint64_to_big_endian( uint64_t value, uint8_t *data)
{
ssize_t i = 0;
int i;
for (i = 7; i >= 0; --i) {
data [i] = (uint8_t) value;

View File

@@ -71,6 +71,43 @@ SPARC_ASSERT_OFFSET(isr_dispatch_disable, ISR_DISPATCH_DISABLE_STACK);
SPARC_ASSERT_OFFSET(is_executing, SPARC_CONTEXT_CONTROL_IS_EXECUTING);
#endif
#define SPARC_ASSERT_ISF_OFFSET(field, off) \
RTEMS_STATIC_ASSERT( \
offsetof(CPU_Interrupt_frame, field) == ISF_ ## off ## _OFFSET, \
CPU_Interrupt_frame_offset_ ## field \
)
SPARC_ASSERT_ISF_OFFSET(psr, PSR);
SPARC_ASSERT_ISF_OFFSET(pc, PC);
SPARC_ASSERT_ISF_OFFSET(npc, NPC);
SPARC_ASSERT_ISF_OFFSET(g1, G1);
SPARC_ASSERT_ISF_OFFSET(g2, G2);
SPARC_ASSERT_ISF_OFFSET(g3, G3);
SPARC_ASSERT_ISF_OFFSET(g4, G4);
SPARC_ASSERT_ISF_OFFSET(g5, G5);
SPARC_ASSERT_ISF_OFFSET(g7, G7);
SPARC_ASSERT_ISF_OFFSET(i0, I0);
SPARC_ASSERT_ISF_OFFSET(i1, I1);
SPARC_ASSERT_ISF_OFFSET(i2, I2);
SPARC_ASSERT_ISF_OFFSET(i3, I3);
SPARC_ASSERT_ISF_OFFSET(i4, I4);
SPARC_ASSERT_ISF_OFFSET(i5, I5);
SPARC_ASSERT_ISF_OFFSET(i6_fp, I6_FP);
SPARC_ASSERT_ISF_OFFSET(i7, I7);
SPARC_ASSERT_ISF_OFFSET(y, Y);
SPARC_ASSERT_ISF_OFFSET(tpc, TPC);
RTEMS_STATIC_ASSERT(
sizeof(CPU_Interrupt_frame) == CONTEXT_CONTROL_INTERRUPT_FRAME_SIZE,
CPU_Interrupt_frame_size
);
/* https://devel.rtems.org/ticket/2352 */
RTEMS_STATIC_ASSERT(
sizeof(CPU_Interrupt_frame) % CPU_ALIGNMENT == 0,
CPU_Interrupt_frame_alignment
);
/*
* _CPU_Initialize
*

View File

@@ -547,9 +547,6 @@ typedef struct {
#define SPARC_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 0x58
#endif
/** This defines the size of the context area for use in assembly. */
#define CONTEXT_CONTROL_SIZE 0x68
#ifndef ASM
/**
* @brief SPARC basic context.
@@ -700,8 +697,6 @@ typedef struct {
* Offsets of fields with CPU_Interrupt_frame for assembly routines.
*/
/** This macro defines an offset into the ISF for use in assembly. */
#define ISF_STACK_FRAME_OFFSET 0x00
/** This macro defines an offset into the ISF for use in assembly. */
#define ISF_PSR_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x00
/** This macro defines an offset into the ISF for use in assembly. */

View File

@@ -388,8 +388,6 @@ typedef struct {
#define ISR_DISPATCH_DISABLE_STACK_OFFSET 0xF8
#define ISR_PAD_OFFSET 0xFC
#define CONTEXT_CONTROL_SIZE 0x100
/*
* The floating point context area.
*/
@@ -518,7 +516,6 @@ typedef struct {
* Offsets of fields with CPU_Interrupt_frame for assembly routines.
*/
#define ISF_STACK_FRAME_OFFSET 0x00
#define ISF_TSTATE_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x00
#define ISF_TPC_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x08
#define ISF_TNPC_OFFSET CPU_MINIMUM_STACK_FRAME_SIZE + 0x10

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 embedded brains GmbH. All rights reserved.
* Copyright (c) 2013-2015 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -30,7 +30,7 @@ const char rtems_test_name[] = "SPCONTEXT 1";
typedef struct {
rtems_id control_task;
rtems_id validate_tasks[2];
rtems_id validate_tasks[3];
rtems_id timer;
size_t task_index;
int iteration_counter;
@@ -90,22 +90,22 @@ static void switch_priorities(test_context *self)
{
rtems_status_code sc;
size_t index = self->task_index;
size_t next = (index + 1) & 0x1;
size_t task_high = index;
size_t task_low = next;
size_t next = (index + 1) % RTEMS_ARRAY_SIZE(self->validate_tasks);
size_t task_current_high = index;
size_t task_next_high = next;
rtems_task_priority priority;
self->task_index = next;
sc = rtems_task_set_priority(
self->validate_tasks[task_high],
self->validate_tasks[task_next_high],
PRIORITY_HIGH,
&priority
);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
sc = rtems_task_set_priority(
self->validate_tasks[task_low],
self->validate_tasks[task_current_high],
PRIORITY_LOW,
&priority
);
@@ -149,11 +149,17 @@ static void wait_for_finish(void)
rtems_test_assert(out == FINISH_EVENT);
}
static void test(test_context *self, bool task_0_fpu, bool task_1_fpu)
static void test(
test_context *self,
bool task_0_fpu,
bool task_1_fpu,
bool task_2_fpu
)
{
rtems_status_code sc;
uintptr_t pattern_0 = (uintptr_t) 0xaaaaaaaaaaaaaaaaU;
uintptr_t pattern_1 = (uintptr_t) 0x5555555555555555U;
uintptr_t pattern_2 = (uintptr_t) 0x0000000000000000U;
memset(self, 0, sizeof(*self));
@@ -161,15 +167,21 @@ static void test(test_context *self, bool task_0_fpu, bool task_1_fpu)
start_validate_task(
&self->validate_tasks[0],
pattern_0,
PRIORITY_LOW,
PRIORITY_HIGH,
task_0_fpu
);
start_validate_task(
&self->validate_tasks[1],
pattern_1,
PRIORITY_HIGH,
PRIORITY_LOW,
task_1_fpu
);
start_validate_task(
&self->validate_tasks[2],
pattern_2,
PRIORITY_LOW,
task_2_fpu
);
start_timer(self);
wait_for_finish();
@@ -179,6 +191,9 @@ static void test(test_context *self, bool task_0_fpu, bool task_1_fpu)
sc = rtems_task_delete(self->validate_tasks[1]);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
sc = rtems_task_delete(self->validate_tasks[2]);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
sc = rtems_timer_delete(self->timer);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
@@ -226,16 +241,23 @@ static void test_context_is_executing(void)
static void Init(rtems_task_argument arg)
{
test_context *self = &test_instance;
int i;
int j;
int k;
TEST_BEGIN();
test_context_is_executing();
test(self, false, false);
printf("Both tasks did not use FPU: done\n");
test(self, false, true);
printf("One task used the FPU: done\n");
test(self, true, true);
printf("Both tasks used the FPU: done\n");
for (i = 0; i < 2; ++i) {
for (j = 0; j < 2; ++j) {
for (k = 0; k < 2; ++k) {
printf("Test configuration %d %d %d... ", i, j, k);
test(self, i == 0, j == 0, k == 0);
printf("done\n");
}
}
}
TEST_END();
@@ -247,7 +269,7 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 3
#define CONFIGURE_MAXIMUM_TASKS 4
#define CONFIGURE_MAXIMUM_TIMERS 1
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION

View File

@@ -1,5 +1,10 @@
*** BEGIN OF TEST SPCONTEXT 1 ***
Both tasks did not use FPU: done
One task used the FPU: done
Both tasks used the FPU: done
Test configuration 0 0 0... done
Test configuration 0 0 1... done
Test configuration 0 1 0... done
Test configuration 0 1 1... done
Test configuration 1 0 0... done
Test configuration 1 0 1... done
Test configuration 1 1 0... done
Test configuration 1 1 1... done
*** END OF TEST SPCONTEXT 1 ***