From ea4b8ca65c198b0071581ee2aae09bd0e9e8f414 Mon Sep 17 00:00:00 2001 From: mahi Date: Wed, 16 Mar 2011 15:15:27 +0100 Subject: [PATCH] Added kernel_extra example. Added CW support again. --- boards/board_common.mk | 4 +- boards/mpc551xsim/build_config.mk | 2 +- .../mpc551xsim/examples/kernel_extra/Os_Cfg.c | 190 +++++++ .../mpc551xsim/examples/kernel_extra/Os_Cfg.h | 104 ++++ .../examples/kernel_extra/build_config.mk | 7 + .../examples/kernel_extra/example_info.txt | 13 + .../examples/kernel_extra/kernel_extra.arxml | 487 ++++++++++++++++++ .../examples/kernel_extra/kernel_extra.c | 108 ++++ .../mpc551xsim/examples/kernel_extra/makefile | 45 ++ common/msl_port.c | 1 + examples/system_hooks.c | 193 +++++++ include/Compiler.h | 4 +- include/irq.h | 2 +- include/os_config_macros.h | 27 - include/sys/queue.h | 475 +++++++++++++++++ scripts/cc_cw.mk | 3 +- scripts/rules.mk | 2 + system/kernel/isr.c | 5 +- system/kernel/semaphore.c | 2 - 19 files changed, 1636 insertions(+), 38 deletions(-) create mode 100644 boards/mpc551xsim/examples/kernel_extra/Os_Cfg.c create mode 100644 boards/mpc551xsim/examples/kernel_extra/Os_Cfg.h create mode 100644 boards/mpc551xsim/examples/kernel_extra/build_config.mk create mode 100644 boards/mpc551xsim/examples/kernel_extra/example_info.txt create mode 100644 boards/mpc551xsim/examples/kernel_extra/kernel_extra.arxml create mode 100644 boards/mpc551xsim/examples/kernel_extra/kernel_extra.c create mode 100644 boards/mpc551xsim/examples/kernel_extra/makefile create mode 100644 examples/system_hooks.c create mode 100644 include/sys/queue.h diff --git a/boards/board_common.mk b/boards/board_common.mk index 2e6efe27..90ea782a 100644 --- a/boards/board_common.mk +++ b/boards/board_common.mk @@ -275,8 +275,8 @@ vpath-y += $(ROOTDIR)/diagnostic/Det # include files need by us inc-y += $(ROOTDIR)/include -inc-y += $(ROOTDIR)/kernel/test -inc-y += $(ROOTDIR)/kernel/include +inc-y += $(ROOTDIR)/system/kernel/test +inc-y += $(ROOTDIR)/system/kernel/include inc-y += $(ROOTDIR)/$(ARCH_PATH-y)/kernel inc-y += $(ROOTDIR)/$(ARCH_PATH-y)/drivers inc-y += $(ROOTDIR)/boards/$(BOARDDIR)/config diff --git a/boards/mpc551xsim/build_config.mk b/boards/mpc551xsim/build_config.mk index cef39fdb..c315086f 100644 --- a/boards/mpc551xsim/build_config.mk +++ b/boards/mpc551xsim/build_config.mk @@ -13,6 +13,6 @@ CFG=PPC BOOKE E200Z1 MPC55XX MPC5516 BRD_MPC551XSIM SIMULATOR # Memory + Peripherals MOD_AVAIL+=ADC DIO DMA CAN GPT LIN MCU PORT PWM WDG # System + Communication + Diagnostic -MOD_AVAIL+=CANIF CANTP COM DCM DEM DET ECUM IOHWAB KERNEL PDUR WDGM RTE +MOD_AVAIL+=CANIF CANTP COM DCM DEM DET ECUM IOHWAB KERNEL PDUR WDGM RTE KERNEL_EXTRA # Additional MOD_AVAIL+=RAMLOG KERNEL_EXTRA diff --git a/boards/mpc551xsim/examples/kernel_extra/Os_Cfg.c b/boards/mpc551xsim/examples/kernel_extra/Os_Cfg.c new file mode 100644 index 00000000..a67367b9 --- /dev/null +++ b/boards/mpc551xsim/examples/kernel_extra/Os_Cfg.c @@ -0,0 +1,190 @@ +/* +* Configuration of module: Os (Os_Cfg.c) +* +* Created by: +* Copyright: +* +* Configured for (MCU): MPC551x +* +* Module vendor: ArcCore +* Generator version: 2.0.22 +* +* Generated by Arctic Studio (http://arccore.com) +* on Wed Mar 16 09:05:04 CET 2011 +*/ + + + +#include +#include +#include "Platform_Types.h" +#include "Os.h" // includes Os_Cfg.h +#include "os_config_macros.h" +#include "kernel.h" +//#include "isr.h" +//#include "kernel_offset.h" +#include "alist_i.h" +#include "Mcu.h" + +// ############################### EXTERNAL REFERENCES ############################# + +/* Application externals */ + +/* Interrupt externals */ +void Mcu_LossOfClock ( void ); +void Mcu_LossOfLock ( void ); +void OsTick ( void ); + + +// Set the os tick frequency +OsTickType OsTickFreq = 1000; + + +// ############################### DEBUG OUTPUT ############################# +uint32 os_dbg_mask = 0; + +// ############################### APPLICATIONS ############################# +GEN_APPLICATION_HEAD = { + GEN_APPLICATION( + /* id */ APPLICATION_ID_OsApplication1, + /* name */ "OsApplication1", + /* trusted */ true, /* NOT CONFIGURABLE IN TOOLS */ + 0, + /* StartupHook */ NULL, /* Startup Hook */ + /* ShutdownHook */ NULL, /* Shutdown Hook */ + /* ErrorHook */ NULL, /* Error Hook */ + /* rstrtTaskId */ 0 /* NOT CONFIGURABLE IN TOOLS */ + ), +}; +// ################################# COUNTERS ############################### +GEN_COUNTER_HEAD = { + GEN_COUNTER( COUNTER_ID_Counter1, + "Counter1", + COUNTER_TYPE_HARD, + COUNTER_UNIT_NANO, + 0xffff, + 1, + 1, + 0, + APPLICATION_ID_OsApplication1, /* Application owner */ + 0 /* Accessing application mask */ + ), +}; + +CounterType Os_Arc_OsTickCounter = COUNTER_ID_Counter1; + +// ################################## ALARMS ################################ + +GEN_ALARM_HEAD = { + GEN_ALARM( ALARM_ID_Alarm1, + "Alarm1", + COUNTER_ID_Counter1, + NULL, + ALARM_ACTION_ACTIVATETASK, + TASK_ID_bTask, + NULL, + NULL, + APPLICATION_ID_OsApplication1, /* Application owner */ + 0 /* Accessing application mask */ + ), +}; + +// ################################ RESOURCES ############################### +GEN_RESOURCE_HEAD = { + GEN_RESOURCE( + RES_ID_Resource1, + RESOURCE_TYPE_STANDARD, + 0, + APPLICATION_ID_OsApplication1, /* Application owner */ + 0 /* Accessing application mask */ + ), +}; + +// ############################## STACKS (TASKS) ############################ +DECLARE_STACK(OsIdle,OS_OSIDLE_STACK_SIZE); +DECLARE_STACK(bTask,512); +DECLARE_STACK(eTask1,512); + +// ################################## TASKS ################################# +GEN_TASK_HEAD = { + GEN_ETASK( OsIdle, + "OsIdle", + 0, + FULL, + TRUE, + NULL, + RES_SCHEDULER, + 0, + 0 + ), + GEN_BTASK( + /* */bTask, + /* name */"bTask", + /* priority */31, + /* schedule */FULL, + /* autostart */FALSE, + /* resource_int_p */NULL, + /* resource mask */0, + /* activation lim. */1, + /* App owner */APPLICATION_ID_OsApplication1, + /* Accessing apps */0 + ), + GEN_ETASK( + /* */eTask1, + /* name */"eTask1", + /* priority */1, + /* schedule */FULL, + /* name */TRUE, + /* resource_int_p */NULL, + /* resource mask */0, + /* App owner */APPLICATION_ID_OsApplication1, + /* Accessing apps */0 + ), +}; + +// ################################## HOOKS ################################# +GEN_HOOKS( + StartupHook, + NULL, + ShutdownHook, + ErrorHook, + PreTaskHook, + PostTaskHook +); + +// ################################## ISRS ################################## +GEN_ISR_HEAD = { + GEN_ISR1( + /* name */ "LossOfClock", + /* vector */ PLL_SYNSR_LOCF, + /* priority */ 5, + /* entry */ Mcu_LossOfClock, + /* appOwner */ APPLICATION_ID_OsApplication1 + ), + GEN_ISR1( + /* name */ "LossOfLock", + /* vector */ PLL_SYNSR_LOLF, + /* priority */ 5, + /* entry */ Mcu_LossOfLock, + /* appOwner */ APPLICATION_ID_OsApplication1 + ), + GEN_ISR2( + /* name */ "TickTrigg", + /* vector */ INTC_SSCIR0_CLR7, + /* priority */ 6, + /* entry */ OsTick, + /* appOwner */ APPLICATION_ID_OsApplication1, + /* rsrcMask */ 1 + ), +}; + +GEN_ISR_MAP = { + [PLL_SYNSR_LOCF] = 0, + [PLL_SYNSR_LOLF] = 1, + [INTC_SSCIR0_CLR7] = 2, +}; + +// ############################ SCHEDULE TABLES ############################# + + +#include "os_config_funcs.h" diff --git a/boards/mpc551xsim/examples/kernel_extra/Os_Cfg.h b/boards/mpc551xsim/examples/kernel_extra/Os_Cfg.h new file mode 100644 index 00000000..8b32a8c5 --- /dev/null +++ b/boards/mpc551xsim/examples/kernel_extra/Os_Cfg.h @@ -0,0 +1,104 @@ +/* +* Configuration of module: Os (Os_Cfg.h) +* +* Created by: +* Copyright: +* +* Configured for (MCU): MPC551x +* +* Module vendor: ArcCore +* Generator version: 2.0.22 +* +* Generated by Arctic Studio (http://arccore.com) +* on Wed Mar 16 09:05:04 CET 2011 +*/ + + +#if !(((OS_SW_MAJOR_VERSION == 2) && (OS_SW_MINOR_VERSION == 0)) ) +#error Os: Configuration file expected BSW module version to be 2.0.* +#endif + + + +#ifndef OS_CFG_H_ +#define OS_CFG_H_ + +// Application Id's +#define APPLICATION_ID_OsApplication1 0 + +// Alarm Id's +#define ALARM_ID_Alarm1 0 + +// Counter Id's +#define COUNTER_ID_Counter1 0 + +// Counter macros +#define OSMAXALLOWEDVALUE_Counter1 65535 + + +// Event masks +#define EVENT_MASK_Event1 1 +#define EVENT_MASK_Event2 1 + +// Isr Id's +#define ISR_ID_LossOfClock 0 +#define ISR_ID_LossOfLock 1 +#define ISR_ID_TickTrigg 2 + +// Resource Id's +#define RES_ID_Resource1 0 + +// Linked resource id's + +// Resource masks +#define RES_MASK_Resource1 (1 << 0) + +// Task Id's +#define TASK_ID_OsIdle 0 +#define TASK_ID_bTask 1 +#define TASK_ID_eTask1 2 + +// Task entry points +void OsIdle( void ); +void bTask( void ); +void eTask1( void ); + +// Schedule table id's + +// Stack size +#define OS_INTERRUPT_STACK_SIZE 2048 +#define OS_OSIDLE_STACK_SIZE 512 + +#define OS_ALARM_CNT 1 +#define OS_TASK_CNT 3 +#define OS_SCHTBL_CNT 0 +#define OS_COUNTER_CNT 1 +#define OS_EVENTS_CNT 2 +//#define OS_ISRS_CNT 3 +#define OS_RESOURCE_CNT 1 +#define OS_LINKED_RESOURCE_CNT 0 +#define OS_APPLICATION_CNT 1 +#define OS_SERVICE_CNT 0 /* ARCTICSTUDIO_GENERATOR_TODO */ +#define CFG_OS_DEBUG STD_OFF + +#define OS_SC1 STD_ON /* NOT CONFIGURABLE IN TOOLS */ +#define OS_USE_APPLICATIONS STD_ON +#define OS_USE_MEMORY_PROT STD_OFF /* NOT CONFIGURABLE IN TOOLS */ +#define OS_USE_TASK_TIMING_PROT STD_OFF /* NOT CONFIGURABLE IN TOOLS */ +#define OS_USE_ISR_TIMING_PROT STD_OFF /* NOT CONFIGURABLE IN TOOLS */ +//#define OS_SC3 STD_ON /* NOT CONFIGURABLE IN TOOLS */ +#define OS_STACK_MONITORING STD_ON +#define OS_STATUS_EXTENDED STD_ON +#define OS_USE_GET_SERVICE_ID STD_ON +#define OS_USE_PARAMETER_ACCESS STD_ON +#define OS_RES_SCHEDULER STD_ON /* NOT CONFIGURABLE IN TOOLS */ + +#define OS_ISR_CNT 3 +#define OS_ISR2_CNT 1 +#define OS_ISR1_CNT 2 + +/* New */ +#define OS_ISR_MAX_CNT 10 /* NOT CONFIGURABLE IN TOOLS */ + + +#endif /*OS_CFG_H_*/ diff --git a/boards/mpc551xsim/examples/kernel_extra/build_config.mk b/boards/mpc551xsim/examples/kernel_extra/build_config.mk new file mode 100644 index 00000000..5e494fdc --- /dev/null +++ b/boards/mpc551xsim/examples/kernel_extra/build_config.mk @@ -0,0 +1,7 @@ + +#-include ../config/*.mk +#-include ../config/$(BOARDDIR)/*.mk + +MOD_USE+= DET ECUM MCU KERNEL RAMLOG KERNEL_EXTRA + +#def-y += NDEBUG diff --git a/boards/mpc551xsim/examples/kernel_extra/example_info.txt b/boards/mpc551xsim/examples/kernel_extra/example_info.txt new file mode 100644 index 00000000..6cf7f27a --- /dev/null +++ b/boards/mpc551xsim/examples/kernel_extra/example_info.txt @@ -0,0 +1,13 @@ + +Description + This example contains + + +Build + $ make all + $ make clean + +Configuration + MOD_USE + KERNEL_EXTRA + diff --git a/boards/mpc551xsim/examples/kernel_extra/kernel_extra.arxml b/boards/mpc551xsim/examples/kernel_extra/kernel_extra.arxml new file mode 100644 index 00000000..f81beaf4 --- /dev/null +++ b/boards/mpc551xsim/examples/kernel_extra/kernel_extra.arxml @@ -0,0 +1,487 @@ + + + + kernel_extra + + + kernel_extra + + + + + + + MPC551x + /arc_isr/boards/mpc551xsim/examples/kernel_extra + + + + /kernel_extra/SwComposition_kernel_extra + + /kernel_extra/Os + + + + SwComposition_kernel_extra + + + Os + + + + + true + 2.0.21 + + + + /ArcCore/Os + + + OsOS + /ArcCore/Os/OsOS + + + /ArcCore/Os/OsOS/OsStackMonitoring + true + + + /ArcCore/Os/OsOS/OsStatus + EXTENDED + + + /ArcCore/Os/OsOS/OsUseGetServiceId + true + + + /ArcCore/Os/OsOS/OsUseParameterAccess + true + + + /ArcCore/Os/OsOS/OsUseResScheduler + true + + + /ArcCore/Os/OsOS/OsTickFrequency + 1000 + + + /ArcCore/Os/OsOS/OsInterruptStackSize + 2048 + + + /ArcCore/Os/OsOS/OsIdleStackSize + 512 + + + /ArcCore/Os/OsOS/ArcCoreOsUseDebug + false + + + /ArcCore/Os/OsOS/ArcCoreOsDebugTask + false + + + /ArcCore/Os/OsOS/ArcCoreOsDebugAlarm + false + + + /ArcCore/Os/OsOS/ArcCoreOsDebugResource + false + + + /ArcCore/Os/OsOS/ArcCoreOsDebugScheduleTable + false + + + /ArcCore/Os/OsOS/ArcCoreOsDebugEvent + false + + + + + OsHooks + /ArcCore/Os/OsOS/OsHooks + + + /ArcCore/Os/OsOS/OsHooks/OsErrorHook + true + + + /ArcCore/Os/OsOS/OsHooks/OsPostTaskHook + true + + + /ArcCore/Os/OsOS/OsHooks/OsPreTaskHook + true + + + /ArcCore/Os/OsOS/OsHooks/OsProtectionHook + false + + + /ArcCore/Os/OsOS/OsHooks/OsShutdownHook + true + + + /ArcCore/Os/OsOS/OsHooks/OsStartupHook + true + + + + + + + LossOfLock + + + + + + /ArcCore/Os/OsIsr + + + /ArcCore/Os/OsIsr/OsIsrCategory + CATEGORY_1 + + + /ArcCore/Os/OsIsr/ArcOsIsrVector + PLL_SYNSR_LOLF + + + /ArcCore/Os/OsIsr/ArcOsIsrCallbackName + Mcu_LossOfLock + + + /ArcCore/Os/OsIsr/ArcOsIsrPriority + 5 + + + + + eTask1 + + + + + + /ArcCore/Os/OsTask + + + /ArcCore/Os/OsTask/OsTaskActivation + 1 + + + /ArcCore/Os/OsTask/OsTaskPriority + 1 + + + /ArcCore/Os/OsTask/OsTaskProcessType + EXTENDED + + + /ArcCore/Os/OsTask/ArcCoreOsTaskStackSize + 512 + + + /ArcCore/Os/OsTask/OsTaskSchedule + FULL + + + + + /ArcCore/Os/OsTask/OsTaskEventRef + /kernel_extra/Os/Event1 + + + + + OsTaskAutostart + /ArcCore/Os/OsTask/OsTaskAutostart + + + + + Alarm1 + + + + + + /ArcCore/Os/OsAlarm + + + /ArcCore/Os/OsAlarm/OsAlarmCounterRef + /kernel_extra/Os/Counter1 + + + + + OsAlarmAction + /ArcCore/Os/OsAlarm/OsAlarmAction + + + OsAlarmActivateTask + /ArcCore/Os/OsAlarm/OsAlarmAction/OsAlarmActivateTask + + + /ArcCore/Os/OsAlarm/OsAlarmAction/OsAlarmActivateTask/OsAlarmActivateTaskRef + /kernel_extra/Os/bTask + + + + + + + + + Counter1 + + + + + + /ArcCore/Os/OsCounter + + + /ArcCore/Os/OsCounter/OsCounterMaxAllowedValue + 65535 + + + /ArcCore/Os/OsCounter/OsCounterMinCycle + 1 + + + /ArcCore/Os/OsCounter/OsCounterTicksPerBase + 0 + + + /ArcCore/Os/OsCounter/OsCounterType + OS_TICK + + + + + Event1 + + + + + + /ArcCore/Os/OsEvent + + + /ArcCore/Os/OsEvent/OsEventMask + 1 + + + + + LossOfClock + + + + + + /ArcCore/Os/OsIsr + + + /ArcCore/Os/OsIsr/OsIsrCategory + CATEGORY_1 + + + /ArcCore/Os/OsIsr/ArcOsIsrVector + PLL_SYNSR_LOCF + + + /ArcCore/Os/OsIsr/ArcOsIsrCallbackName + Mcu_LossOfClock + + + /ArcCore/Os/OsIsr/ArcOsIsrPriority + 5 + + + + + bTask + + + + + + /ArcCore/Os/OsTask + + + /ArcCore/Os/OsTask/OsTaskActivation + 1 + + + /ArcCore/Os/OsTask/OsTaskPriority + 31 + + + /ArcCore/Os/OsTask/OsTaskProcessType + BASIC + + + /ArcCore/Os/OsTask/ArcCoreOsTaskStackSize + 512 + + + /ArcCore/Os/OsTask/OsTaskSchedule + FULL + + + + + /ArcCore/Os/OsTask/OsTaskEventRef + /kernel_extra/Os/Event2 + + + /ArcCore/Os/OsTask/OsTaskEventRef + /kernel_extra/Os/Event1 + + + + + Event2 + + + + + + /ArcCore/Os/OsEvent + + + /ArcCore/Os/OsEvent/OsEventMask + 1 + + + + + TickTrigg + + + + + + /ArcCore/Os/OsIsr + + + /ArcCore/Os/OsIsr/OsIsrCategory + CATEGORY_2 + + + /ArcCore/Os/OsIsr/ArcOsIsrVector + INTC_SSCIR0_CLR7 + + + /ArcCore/Os/OsIsr/ArcOsIsrCallbackName + OsTick + + + /ArcCore/Os/OsIsr/ArcOsIsrPriority + 6 + + + + + /ArcCore/Os/OsIsr/OsIsrResourceRef + /kernel_extra/Os/Resource1 + + + + + Resource1 + + + + + + /ArcCore/Os/OsResource + + + /ArcCore/Os/OsResource/OsResourceProperty + STANDARD + + + + + OsApplication1 + + + + + + /ArcCore/Os/OsApplication + + + /ArcCore/Os/OsApplication/ArcOsAppCoreId + 0 + + + /ArcCore/Os/OsApplication/OsTrusted + false + + + + + /ArcCore/Os/OsApplication/OsAppAlarmRef + /kernel_extra/Os/Alarm1 + + + /ArcCore/Os/OsApplication/OsAppCounterRef + /kernel_extra/Os/Counter1 + + + /ArcCore/Os/OsApplication/OsAppIsrRef + /kernel_extra/Os/LossOfLock + + + /ArcCore/Os/OsApplication/OsAppIsrRef + /kernel_extra/Os/LossOfClock + + + /ArcCore/Os/OsApplication/OsAppIsrRef + /kernel_extra/Os/TickTrigg + + + /ArcCore/Os/OsApplication/OsAppResourceRef + /kernel_extra/Os/Resource1 + + + /ArcCore/Os/OsApplication/OsAppTaskRef + /kernel_extra/Os/eTask1 + + + /ArcCore/Os/OsApplication/OsAppTaskRef + /kernel_extra/Os/bTask + + + + + OsApplicationHooks + /ArcCore/Os/OsApplication/OsApplicationHooks + + + /ArcCore/Os/OsApplication/OsApplicationHooks/OsAppErrorHook + false + + + /ArcCore/Os/OsApplication/OsApplicationHooks/OsAppShutdownHook + false + + + /ArcCore/Os/OsApplication/OsApplicationHooks/OsAppStartupHook + false + + + + + + + + + + diff --git a/boards/mpc551xsim/examples/kernel_extra/kernel_extra.c b/boards/mpc551xsim/examples/kernel_extra/kernel_extra.c new file mode 100644 index 00000000..69756d2a --- /dev/null +++ b/boards/mpc551xsim/examples/kernel_extra/kernel_extra.c @@ -0,0 +1,108 @@ +/* + * kernel_extra.c + * + * Created on: 13 mar 2011 + * Author: mahi + * + * DESCRIPTION + * Shows the features of KERNEL_EXTRA + * + */ + +#include "Os.h" +#include "isr.h" +#include "irq.h" +#include + +OsMutexType mutex; +OsSemaphoreType semIsr; + +static int state = 0; + +/** + * Function that prints str to stdout and can activate + * another task if interrupt is set. + * + * @param interrupt true if a call to ActivateTask() should be done + * @param str The string tp print + */ + +void mutexPrint( bool interrupt, char *str ) { + WaitMutex(&mutex); + if( interrupt ) { + ActivateTask(TASK_ID_bTask); + } + printf("Mutex protected: %s\n",str); + ReleaseMutex(&mutex); +} + +void resourcePrint( bool interrupt, char *str ) { + GetResource(RES_ID_Resource1); + if( interrupt ) { + ActivateTask(TASK_ID_bTask); + } + printf("Mutex protected: %s\n",str); + ReleaseResource(RES_ID_Resource1); +} + + +void bTask( void ) { + + switch(state) { + case 0: + SignalSemaphore(&semIsr); + break; + case 1: + mutexPrint(false, "from bTask"); + break; + case 2: + resourcePrint(false,"from bTask"); + break; + default: + assert(0); + } + + TerminateTask(); +} + + +void eTask1( void ) { + + for(;;) { + + /* + * Example: Use SignalSemaphore() and WaitSemaphore() + */ + + state = 0; + /* Trigger bTaskSem that calls SignalSemaphore */ + SetRelAlarm(ALARM_ID_Alarm1,2,0); + WaitSemaphore(&semIsr, TICK_MAX); + + /* + * Example: Use a shared resource that is protected with + * WaitMutex() and ReleaseMutex() + */ + state = 1; + mutexPrint( true,"from eTask1"); + + + /* + * Example: Traditional GetResource() and ReleaseResource() calls + */ + state = 2; + resourcePrint( true,"from eTask1"); + + + /* OSEK resources */ + GetResource(RES_ID_Resource1); + Irq_GenerateSoftInt(5); + ReleaseResource(RES_ID_Resource1); + + } +} + +void OsIdle( void ) { + for(;;); +} + diff --git a/boards/mpc551xsim/examples/kernel_extra/makefile b/boards/mpc551xsim/examples/kernel_extra/makefile new file mode 100644 index 00000000..3c382153 --- /dev/null +++ b/boards/mpc551xsim/examples/kernel_extra/makefile @@ -0,0 +1,45 @@ + + + +export CROSS_COMPILE=/opt/powerpc-eabispe/bin/powerpc-eabispe- + +root_path=$(abspath $(CURDIR)/../../../..) +board_path=$(abspath $(CURDIR)/../..) + +ifeq (${MAKELEVEL},0) +boarddir=$(subst $(root_path)/boards/,,$(board_path)) + +.PHONY: all clean +all: + $(Q)$(MAKE) -C $(root_path) BOARDDIR=$(boarddir) BDIR=$(CURDIR) all + +clean: + @echo Cleaning dir $(boarddir) + $(Q)rm -rf obj_$(boarddir) + @echo done! + +export example:=$(subst $(abspath $(CURDIR)/..)/,,$(CURDIR)) +#$(error $(example)) + +else +VPATH += .. +VPATH += $(ROOTDIR)/examples +inc-y += .. + +# Board object files +obj-y += system_hooks.o +obj-y += kernel_extra.o + +include $(ROOTDIR)/boards/board_common.mk + +ldcmdfile-y = linkscript_$(COMPILER).lcf +vpath %.ldf $(ROOTDIR)/$(ARCH_PATH-y)/scripts + +# What I want to build +build-exe-y = $(example).elf + + +endif + + + diff --git a/common/msl_port.c b/common/msl_port.c index 4bf3dbca..fdd8b9dc 100644 --- a/common/msl_port.c +++ b/common/msl_port.c @@ -57,6 +57,7 @@ void exit(int exit ) { void *sbrk(int inc ) { + (void)inc; /* We use our own malloc */ return (void *)(-1); } diff --git a/examples/system_hooks.c b/examples/system_hooks.c new file mode 100644 index 00000000..b489959e --- /dev/null +++ b/examples/system_hooks.c @@ -0,0 +1,193 @@ + +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ +/* + * DESCRIPTION + * Hold all OSEK system hooks. + */ + +/* ----------------------------[includes]------------------------------------*/ + +#include +#include "Os.h" +#include + +#include "Mcu.h" + +/* ----------------------------[private define]------------------------------*/ +#define ERROR_LOG_SIZE 1 + +//#define USE_LDEBUG_PRINTF 1 +#include "debug.h" + +/* ----------------------------[private macro]-------------------------------*/ + + +/* ----------------------------[private typedef]-----------------------------*/ + +typedef struct ErrorEntry { + StatusType error; + OsErrorType info; + TaskType taskId; + OsServiceIdType serviceId; +} ErrorEntryType; + + +typedef struct ErrorLog { + int index; + ErrorEntryType log[ERROR_LOG_SIZE]; +} ErrorLogType; + +struct LogBad { + uint32_t param1; + uint32_t param2; + uint32_t param3; + TaskType taskId; + OsServiceIdType serviceId; + StatusType error; +} LogBadType; + + +/* ----------------------------[private function prototypes]-----------------*/ +/* ----------------------------[private variables]---------------------------*/ +ErrorLogType ErrorLog; +/* ----------------------------[private functions]---------------------------*/ +/* ----------------------------[public functions]----------------------------*/ + +/** + * + * @param FatalError + * @return + */ +ProtectionReturnType ProtectionHook( StatusType FatalError ) { + printf("## ProtectionHook\n"); + return PRO_KILLAPPL; +} + +/** + * + */ +void StartupHook( void ) { +// LDEBUG_PRINTF("## StartupHook\n"); + + uint32_t sys_freq = McuE_GetSystemClock(); + (void)sys_freq; + LDEBUG_PRINTF("Sys clock %d Hz\n",sys_freq); +} + +/** + * + * @param Error + */ +void ShutdownHook( StatusType error ) { + LDEBUG_FPUTS("## ShutdownHook\n"); + (void)error; + while(1) { + //err = err; + ; + } +} + +/** + * + * @param error + */ +void ErrorHook( StatusType error ) { + + TaskType task; + static struct LogBad LogBad[ERROR_LOG_SIZE]; + static uint8_t ErrorCount = 0; + + GetTaskID(&task); + + + OsServiceIdType service = OSErrorGetServiceId(); + + /* Grab the arguments to the functions + * This is the standard way, see 11.2 in OSEK spec + */ + switch(service) { + case OSServiceId_SetRelAlarm: + { + // Read the arguments to the faulty functions... + AlarmType alarm_id = OSError_SetRelAlarm_AlarmId; + TickType increment = OSError_SetRelAlarm_Increment; + TickType cycle = OSError_SetRelAlarm_Cycle; + (void)alarm_id; + (void)increment; + (void)cycle; + + // ... Handle this some way. + break; + } + /* + * The same pattern as above applies for all other OS functions. + * See Os.h for names and definitions. + */ + + default: + break; + } + + LDEBUG_PRINTF("## ErrorHook err=%u\n",Error); + + /* Log the errors in a buffer for later review */ + LogBad[ErrorCount].param1 = os_error.param1; + LogBad[ErrorCount].param2 = os_error.param2; + LogBad[ErrorCount].param3 = os_error.param3; + LogBad[ErrorCount].serviceId = service; + LogBad[ErrorCount].taskId = task; + LogBad[ErrorCount].error = error; + + ErrorCount++; + + // Stall if buffer is full. + while(ErrorCount >= ERROR_LOG_SIZE); +} + + +/** + * + */ +void PreTaskHook( void ) { + StatusType rv; + TaskType task; + TaskStateType state; + + rv = GetTaskID(&task); + assert( rv == E_OK ); + LDEBUG_PRINTF("## PreTaskHook, taskid=%d\n",task); + rv = GetTaskState(task,&state); + assert( rv == E_OK ); + assert( state == TASK_STATE_RUNNING ); +} + +/** + * + */ +void PostTaskHook( void ) { + StatusType rv; + TaskType task; + TaskStateType state; + + rv = GetTaskID(&task); + assert( rv == E_OK ); + LDEBUG_PRINTF("## PostTaskHook, taskid=%d\n",task); + rv = GetTaskState(task,&state); + assert( rv == E_OK ); + assert( state == TASK_STATE_RUNNING ); + +} + diff --git a/include/Compiler.h b/include/Compiler.h index 059b03ce..50131641 100644 --- a/include/Compiler.h +++ b/include/Compiler.h @@ -38,8 +38,8 @@ #if defined(__GNUC__) #define SECTION_BALIGN(_align ) __attribute__ ((aligned (_align))) -#else -#error SECTION_BALIGN not defined for compiler +#elif defined(__CWCC__) +#define SECTION_BALIGN(_align ) __attribute__ ((aligned (_align))) #endif diff --git a/include/irq.h b/include/irq.h index 785156b1..9c43383b 100644 --- a/include/irq.h +++ b/include/irq.h @@ -18,7 +18,7 @@ #define IRQ_H_ #include -#include "os.h" +#include "Os.h" #include "irq_types.h" #include "bit.h" diff --git a/include/os_config_macros.h b/include/os_config_macros.h index 905c4a96..4a9d7583 100644 --- a/include/os_config_macros.h +++ b/include/os_config_macros.h @@ -136,33 +136,6 @@ #define GEN_ISR_MAP const uint8_t Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS] -#if 0 -#define GEN_ISR_2( _id, _name, _entry, _priority, _vector ) \ -{ \ - .pid = _id, \ - .name = _name, \ - .entry = _entry, \ - .prio = _priority, \ - .proc_type = PROC_ISR2, \ - .vector = _vector, \ -} - - -#define GEN_ISR_1( _id, _name, _entry, _priority , _vector ) \ -{ \ - .pid = _id, \ - .name = _name, \ - .entry = _entry, \ - .prio = _priority, \ - .proc_type = PROC_ISR1, \ - .vector = _vector, \ -} -#endif - - -//#define GEN_PCB_LIST() uint8_t Os_TaskVarList[PCB_T_SIZE*ARRAY_SIZE( Os_TaskConstList)]; -#define GEN_PCB_LIST() OsTaskVarType Os_TaskVarList[ARRAY_SIZE( Os_TaskConstList)]; - #define GEN_RESOURCE_HEAD OsResourceType resource_list[OS_RESOURCE_CNT] diff --git a/include/sys/queue.h b/include/sys/queue.h new file mode 100644 index 00000000..23e0d8ac --- /dev/null +++ b/include/sys/queue.h @@ -0,0 +1,475 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + * $FreeBSD: src/sys/sys/queue.h,v 1.48 2002/04/17 14:00:37 tmm Exp $ + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +//#include /* for __offsetof */ +#include /* for __offsetof */ + + + + +/* + * This file defines four types of data structures: singly-linked lists, + * singly-linked tail queues, lists and tail queues. + * + * A singly-linked list is headed by a single forward pointer. The elements + * are singly linked for minimum space and pointer manipulation overhead at + * the expense of O(n) removal for arbitrary elements. New elements can be + * added to the list after an existing element or at the head of the list. + * Elements being removed from the head of the list should use the explicit + * macro for this purpose for optimum efficiency. A singly-linked list may + * only be traversed in the forward direction. Singly-linked lists are ideal + * for applications with large datasets and few or no removals or for + * implementing a LIFO queue. + * + * A singly-linked tail queue is headed by a pair of pointers, one to the + * head of the list and the other to the tail of the list. The elements are + * singly linked for minimum space and pointer manipulation overhead at the + * expense of O(n) removal for arbitrary elements. New elements can be added + * to the list after an existing element, at the head of the list, or at the + * end of the list. Elements being removed from the head of the tail queue + * should use the explicit macro for this purpose for optimum efficiency. + * A singly-linked tail queue may only be traversed in the forward direction. + * Singly-linked tail queues are ideal for applications with large datasets + * and few or no removals or for implementing a FIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * For details on the use of these macros, see the queue(3) manual page. + * + * + * SLIST LIST STAILQ TAILQ + * _HEAD + + + + + * _HEAD_INITIALIZER + + + + + * _ENTRY + + + + + * _INIT + + + + + * _EMPTY + + + + + * _FIRST + + + + + * _NEXT + + + + + * _PREV - - - + + * _LAST - - + + + * _FOREACH + + + + + * _FOREACH_REVERSE - - - + + * _INSERT_HEAD + + + + + * _INSERT_BEFORE - + - + + * _INSERT_AFTER + + + + + * _INSERT_TAIL - - + + + * _CONCAT - - + + + * _REMOVE_HEAD + - + - + * _REMOVE + + + + + * + */ + +/* + * Singly-linked List declarations. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) + +#define SLIST_FIRST(head) ((head)->slh_first) + +#define SLIST_FOREACH(var, head, field) \ + for ((var) = SLIST_FIRST((head)); \ + (var); \ + (var) = SLIST_NEXT((var), field)) + +#define SLIST_INIT(head) do { \ + SLIST_FIRST((head)) = NULL; \ +} while (0) + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ + SLIST_NEXT((slistelm), field) = (elm); \ +} while (0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ + SLIST_FIRST((head)) = (elm); \ +} while (0) + +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + if (SLIST_FIRST((head)) == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = SLIST_FIRST((head)); \ + while (SLIST_NEXT(curelm, field) != (elm)) \ + curelm = SLIST_NEXT(curelm, field); \ + SLIST_NEXT(curelm, field) = \ + SLIST_NEXT(SLIST_NEXT(curelm, field), field); \ + } \ +} while (0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ +} while (0) + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first;/* first element */ \ + struct type **stqh_last;/* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_CONCAT(head1, head2) do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = (head2)->stqh_first; \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ +} while (0) + +#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) + +#define STAILQ_FIRST(head) ((head)->stqh_first) + +#define STAILQ_FOREACH(var, head, field) \ + for((var) = STAILQ_FIRST((head)); \ + (var); \ + (var) = STAILQ_NEXT((var), field)) + +#define STAILQ_INIT(head) do { \ + STAILQ_FIRST((head)) = NULL; \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ +} while (0) + +#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_NEXT((tqelm), field) = (elm); \ +} while (0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ + STAILQ_FIRST((head)) = (elm); \ +} while (0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + STAILQ_NEXT((elm), field) = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &STAILQ_NEXT((elm), field); \ +} while (0) + +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *) \ + ((char *)((head)->stqh_last) - __offsetof(struct type, field)))) + +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if (STAILQ_FIRST((head)) == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = STAILQ_FIRST((head)); \ + while (STAILQ_NEXT(curelm, field) != (elm)) \ + curelm = STAILQ_NEXT(curelm, field); \ + if ((STAILQ_NEXT(curelm, field) = \ + STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\ + (head)->stqh_last = &STAILQ_NEXT((curelm), field);\ + } \ +} while (0) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if ((STAILQ_FIRST((head)) = \ + STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ +} while (0) + +#define STAILQ_REMOVE_HEAD_UNTIL(head, elm, field) do { \ + if ((STAILQ_FIRST((head)) = STAILQ_NEXT((elm), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ +} while (0) + +/* + * List declarations. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ + +#define LIST_EMPTY(head) ((head)->lh_first == NULL) + +#define LIST_FIRST(head) ((head)->lh_first) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = LIST_FIRST((head)); \ + (var); \ + (var) = LIST_NEXT((var), field)) + +#define LIST_INIT(head) do { \ + LIST_FIRST((head)) = NULL; \ +} while (0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ + LIST_NEXT((listelm), field)->field.le_prev = \ + &LIST_NEXT((elm), field); \ + LIST_NEXT((listelm), field) = (elm); \ + (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ +} while (0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + LIST_NEXT((elm), field) = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ +} while (0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ + LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ + LIST_FIRST((head)) = (elm); \ + (elm)->field.le_prev = &LIST_FIRST((head)); \ +} while (0) + +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_REMOVE(elm, field) do { \ + if (LIST_NEXT((elm), field) != NULL) \ + LIST_NEXT((elm), field)->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = LIST_NEXT((elm), field); \ +} while (0) + +/* + * Tail queue declarations. + */ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ +} + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} + +/* + * Tail queue functions. + */ +#define TAILQ_CONCAT(head1, head2, field) do { \ + if (!TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last = (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + } \ +} while (0) + +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) + +#define TAILQ_FIRST(head) ((head)->tqh_first) + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = TAILQ_FIRST((head)); \ + (var); \ + (var) = TAILQ_NEXT((var), field)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var); \ + (var) = TAILQ_PREV((var), headname, field)) + +#define TAILQ_INIT(head) do { \ + TAILQ_FIRST((head)) = NULL; \ + (head)->tqh_last = &TAILQ_FIRST((head)); \ +} while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + TAILQ_NEXT((listelm), field) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ +} while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + TAILQ_NEXT((elm), field) = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ +} while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ + TAILQ_FIRST((head))->field.tqe_prev = \ + &TAILQ_NEXT((elm), field); \ + else \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ + TAILQ_FIRST((head)) = (elm); \ + (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ +} while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + TAILQ_NEXT((elm), field) = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &TAILQ_NEXT((elm), field); \ +} while (0) + +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) + +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + +#define TAILQ_REMOVE(head, elm, field) do { \ + if ((TAILQ_NEXT((elm), field)) != NULL) \ + TAILQ_NEXT((elm), field)->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ +} while (0) + + +#ifdef _KERNEL + +/* + * XXX insque() and remque() are an old way of handling certain queues. + * They bogusly assumes that all queue heads look alike. + */ + +struct quehead { + struct quehead *qh_link; + struct quehead *qh_rlink; +}; + +#ifdef __GNUC__ + +static __inline void +insque(void *a, void *b) +{ + struct quehead *element = (struct quehead *)a, + *head = (struct quehead *)b; + + element->qh_link = head->qh_link; + element->qh_rlink = head; + head->qh_link = element; + element->qh_link->qh_rlink = element; +} + +static __inline void +remque(void *a) +{ + struct quehead *element = (struct quehead *)a; + + element->qh_link->qh_rlink = element->qh_rlink; + element->qh_rlink->qh_link = element->qh_link; + element->qh_rlink = 0; +} + +#else /* !__GNUC__ */ + +void insque(void *a, void *b); +void remque(void *a); + +#endif /* __GNUC__ */ + +#endif /* _KERNEL */ + +#endif /* !_SYS_QUEUE_H_ */ diff --git a/scripts/cc_cw.mk b/scripts/cc_cw.mk index a74cc0de..516e40c0 100644 --- a/scripts/cc_cw.mk +++ b/scripts/cc_cw.mk @@ -63,14 +63,13 @@ CCOUT = -o $@ CPP = $(CC) -E -CPP_ASM_FLAGS += -ppopt noline -dialect c +CPP_ASM_FLAGS += -ppopt noline -ppopt nopragma -dialect c comma = , empty = space = $(empty) $(empty) - cw_lib_path += -L$(CW_COMPILE)/PowerPC_EABI_Support/Runtime/Lib cw_lib_path += -L$(CW_COMPILE)/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Lib cc_inc_path += $(CW_COMPILE)/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include diff --git a/scripts/rules.mk b/scripts/rules.mk index ddbfac7e..635943eb 100644 --- a/scripts/rules.mk +++ b/scripts/rules.mk @@ -258,6 +258,8 @@ $(build-exe-y): $(dep-y) $(obj-y) $(sim-y) $(libitem-y) $(ldcmdfile-y) ifeq ($(CROSS_COMPILE),) $(Q)$(CC) $(LDFLAGS) -o $@ $(libpath-y) $(obj-y) $(lib-y) $(libitem-y) else + @echo LDFLAGS $(LDFLAGS) + @echo LD_FILE $(LD_FILE) $(Q)$(LD) $(LDFLAGS) $(LD_FILE) $(ldcmdfile-y) -o $@ $(libpath-y) $(LD_START_GRP) $(obj-y) $(lib-y) $(libitem-y) $(LD_END_GRP) $(LDMAPFILE) ifdef CFG_MC912DG128A # Print memory layout diff --git a/system/kernel/isr.c b/system/kernel/isr.c index c18420e2..f3fb5bbb 100644 --- a/system/kernel/isr.c +++ b/system/kernel/isr.c @@ -14,14 +14,15 @@ * -------------------------------- Arctic Core ------------------------------*/ +#if defined(__GNUC__) #include +#endif #include #include #include "Compiler.h" #include "internal.h" #include "isr.h" #include "irq.h" -//#include "irq_config.h" extern const uint8_t Os_VectorToIsr[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS]; @@ -40,6 +41,7 @@ SECTION_BALIGN(0x10) uint8_t Os_IsrStack[OS_INTERRUPT_STACK_SIZE]; //#include "stm32f10x_arc.h" #endif +#if 0 extern caddr_t *sbrk(int); #define os_alloc(_x) sbrk(_x) @@ -50,6 +52,7 @@ OsTaskVarType * os_alloc_new_pcb( void ) { assert(h!=NULL); return h; } +#endif //extern TaskType Os_AddTask( OsTaskVarType *pcb ); diff --git a/system/kernel/semaphore.c b/system/kernel/semaphore.c index 8ee59d1c..883c00f7 100644 --- a/system/kernel/semaphore.c +++ b/system/kernel/semaphore.c @@ -152,8 +152,6 @@ void SignalSemaphore( OsSemaphoreType *semPtr ) { } Irq_Restore(flags); - - return E_OK; } -- 2.39.2