git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1637 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
aa71eb0989
commit
5d983fd514
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
/*
|
||||
* Early initialization code.
|
||||
* This initialization is performed just after reset before BSS and DATA
|
||||
* segments initialization.
|
||||
*/
|
||||
void hwinit0(void) {
|
||||
|
||||
spc563_clock_init();
|
||||
}
|
||||
|
||||
/*
|
||||
* Late initialization code.
|
||||
* This initialization is performed after BSS and DATA segments initialization
|
||||
* and before invoking the main() function.
|
||||
*/
|
||||
void hwinit1(void) {
|
||||
|
||||
/*
|
||||
* Various initialization (temporary code).
|
||||
*/
|
||||
SIU.PCR[GPIO_LED1].R = 0x0300; /* OBE | IBE. */
|
||||
SIU.PCR[GPIO_LED2].R = 0x0300; /* OBE | IBE. */
|
||||
SIU.PCR[GPIO_LED3].R = 0x0300; /* OBE | IBE. */
|
||||
SIU.PCR[GPIO_LED4].R = 0x0300; /* OBE | IBE. */
|
||||
SIU.PCR[GPIO_BUTTON1].R = 0x0100; /* IBE. */
|
||||
SIU.PCR[GPIO_BUTTON2].R = 0x0100; /* IBE. */
|
||||
SIU.PCR[GPIO_BUTTON3].R = 0x0100; /* IBE. */
|
||||
SIU.PCR[GPIO_BUTTON4].R = 0x0100; /* IBE. */
|
||||
SIU.PCR[GPIO_SCI_A_TX].R = 0x0500; /* Primary | IBE. */
|
||||
|
||||
/*
|
||||
* HAL initialization.
|
||||
*/
|
||||
halInit();
|
||||
|
||||
/*
|
||||
* ChibiOS/RT initialization.
|
||||
*/
|
||||
chSysInit();
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _BOARD_H_
|
||||
#define _BOARD_H_
|
||||
|
||||
/*
|
||||
* Setup for a generic SPC563 proto board.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Board identifiers.
|
||||
*/
|
||||
#define BOARD_GENERIC_SPC563
|
||||
#define BOARD_NAME "Generic SPC563"
|
||||
|
||||
/*
|
||||
* Board frequencies.
|
||||
*/
|
||||
#if !defined(EXTCLK)
|
||||
#define EXTCLK 8000000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* I/O definitions.
|
||||
*/
|
||||
#define GPIO_SCI_A_TX 89
|
||||
|
||||
#define GPIO_BUTTON1 179
|
||||
#define GPIO_BUTTON2 181
|
||||
#define GPIO_BUTTON3 183
|
||||
#define GPIO_BUTTON4 187
|
||||
|
||||
#define GPIO_LED1 188
|
||||
#define GPIO_LED2 189
|
||||
#define GPIO_LED3 190
|
||||
#define GPIO_LED4 191
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void hwinit0(void);
|
||||
void hwinit1(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BOARD_H_ */
|
|
@ -0,0 +1,5 @@
|
|||
# List of all the board related files.
|
||||
BOARDSRC = ${CHIBIOS}/boards/GENERIC_SPC563/board.c
|
||||
|
||||
# Required include directories
|
||||
BOARDINC = ${CHIBIOS}/boards/GENERIC_SPC563
|
|
@ -0,0 +1,153 @@
|
|||
##############################################################################
|
||||
# Build global options
|
||||
# NOTE: Can be overridden externally.
|
||||
#
|
||||
|
||||
# Compiler options here.
|
||||
ifeq ($(USE_OPT),)
|
||||
USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
|
||||
endif
|
||||
|
||||
# C++ specific options here (added to USE_OPT).
|
||||
ifeq ($(USE_CPPOPT),)
|
||||
USE_CPPOPT = -fno-rtti
|
||||
endif
|
||||
|
||||
# Enable this if you want the linker to remove unused code and data
|
||||
ifeq ($(USE_LINK_GC),)
|
||||
USE_LINK_GC = no
|
||||
endif
|
||||
|
||||
# Enable register caching optimization (read documentation).
|
||||
# Option not tested on MSP430, DO NOT USE.
|
||||
ifeq ($(USE_CURRP_CACHING),)
|
||||
USE_CURRP_CACHING = no
|
||||
endif
|
||||
|
||||
#
|
||||
# Build global options
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Project, sources and paths
|
||||
#
|
||||
|
||||
# Define project name here
|
||||
PROJECT = ch
|
||||
|
||||
# Define linker script file here
|
||||
LDSCRIPT = ./ch.ld
|
||||
|
||||
# Imported source files
|
||||
CHIBIOS = ../..
|
||||
include $(CHIBIOS)/boards/GENERIC_SPC563/board.mk
|
||||
include $(CHIBIOS)/os/hal/platforms/SPC563/platform.mk
|
||||
include $(CHIBIOS)/os/hal/hal.mk
|
||||
include $(CHIBIOS)/os/ports/GCC/PPC/port.mk
|
||||
include $(CHIBIOS)/os/kernel/kernel.mk
|
||||
include $(CHIBIOS)/test/test.mk
|
||||
|
||||
# C sources here.
|
||||
CSRC = $(PORTSRC) \
|
||||
$(KERNSRC) \
|
||||
$(TESTSRC) \
|
||||
$(HALSRC) \
|
||||
$(PLATFORMSRC) \
|
||||
$(BOARDSRC) \
|
||||
$(CHIBIOS)/os/various/evtimer.c \
|
||||
$(CHIBIOS)/os/various/memstreams.c \
|
||||
main.c
|
||||
|
||||
# C++ sources here.
|
||||
CPPSRC =
|
||||
|
||||
# List ASM source files here
|
||||
ASMSRC = $(PORTASM) \
|
||||
$(CHIBIOS)/os/ports/GCC/PPC/SPC56x/ivor.s \
|
||||
$(CHIBIOS)/os/ports/GCC/PPC/SPC56x/vectors.s
|
||||
|
||||
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
|
||||
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
|
||||
$(CHIBIOS)/os/various
|
||||
|
||||
#
|
||||
# Project, sources and paths
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Compiler settings
|
||||
#
|
||||
|
||||
MCU = e500mc -meabi -msdata=none -mnew-mnemonics -mregnames
|
||||
|
||||
TRGT = powerpc-eabi-
|
||||
CC = $(TRGT)gcc
|
||||
CPPC = $(TRGT)g++
|
||||
# Enable loading with g++ only if you need C++ runtime support.
|
||||
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
||||
# runtime support makes code size explode.
|
||||
LD = $(TRGT)gcc
|
||||
#LD = $(TRGT)g++
|
||||
CP = $(TRGT)objcopy
|
||||
AS = $(TRGT)gcc -x assembler-with-cpp
|
||||
OD = $(TRGT)objdump
|
||||
HEX = $(CP) -O ihex
|
||||
BIN = $(CP) -O binary
|
||||
|
||||
# Define C warning options here
|
||||
CWARN = -Wall -Wextra -Wstrict-prototypes
|
||||
|
||||
# Define C++ warning options here
|
||||
CPPWARN = -Wall -Wextra
|
||||
|
||||
#
|
||||
# Compiler settings
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Start of default section
|
||||
#
|
||||
|
||||
# List all default C defines here, like -D_DEBUG=1
|
||||
DDEFS =
|
||||
|
||||
# List all default ASM defines here, like -D_DEBUG=1
|
||||
DADEFS =
|
||||
|
||||
# List all default directories to look for include files here
|
||||
DINCDIR =
|
||||
|
||||
# List the default directory to look for the libraries here
|
||||
DLIBDIR =
|
||||
|
||||
# List all default libraries here
|
||||
DLIBS =
|
||||
|
||||
#
|
||||
# End of default section
|
||||
##############################################################################
|
||||
|
||||
##############################################################################
|
||||
# Start of user section
|
||||
#
|
||||
|
||||
# List all user C define here, like -D_DEBUG=1
|
||||
UDEFS =
|
||||
|
||||
# Define ASM defines here
|
||||
UADEFS =
|
||||
|
||||
# List all user directories here
|
||||
UINCDIR =
|
||||
|
||||
# List the user directory to look for the libraries here
|
||||
ULIBDIR =
|
||||
|
||||
# List all user libraries here
|
||||
ULIBS =
|
||||
|
||||
#
|
||||
# End of user defines
|
||||
##############################################################################
|
||||
|
||||
include $(CHIBIOS)/os/ports/GCC/PPC/rules.mk
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* SPC563M64 memory setup.
|
||||
*/
|
||||
__irq_stack_size__ = 0x0400;
|
||||
__process_stack_size__ = 0x0800;
|
||||
__stacks_total_size__ = __irq_stack_size__ + __process_stack_size__;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash : org = 0x00000000, len = 1536k
|
||||
ram : org = 0x40000000, len = 94k
|
||||
}
|
||||
|
||||
/*
|
||||
* Derived constants.
|
||||
*/
|
||||
__flash_size__ = LENGTH(flash);
|
||||
__flash_start__ = ORIGIN(flash);
|
||||
__flash_end__ = ORIGIN(flash) + LENGTH(flash);
|
||||
|
||||
__ram_size__ = LENGTH(ram);
|
||||
__ram_start__ = ORIGIN(ram);
|
||||
__ram_end__ = ORIGIN(ram) + LENGTH(ram);
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = ORIGIN(flash);
|
||||
|
||||
.text : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
__ivpr_base__ = .;
|
||||
KEEP(*(.bam))
|
||||
KEEP(*(.handlers))
|
||||
. = ALIGN(0x800);
|
||||
KEEP(*(.vectors))
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
*(.glue_7t);
|
||||
*(.glue_7);
|
||||
*(.ctors);
|
||||
*(.dtors);
|
||||
} > flash
|
||||
|
||||
.rodata : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
*(.rodata1)
|
||||
} > flash
|
||||
|
||||
.sdata2 : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
__sdata2_start__ = . + 0x8000;
|
||||
*(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
|
||||
*(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
|
||||
} > flash
|
||||
|
||||
.romdata : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
__romdata_start__ = .;
|
||||
} > flash
|
||||
|
||||
.data : AT(__romdata_start__)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__data_start__ = .;
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
__sdata_start__ = . + 0x8000;
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.*)
|
||||
__data_end__ = .;
|
||||
} > ram
|
||||
|
||||
.sbss :
|
||||
{
|
||||
__bss_start__ = .;
|
||||
*(.sbss .sbss.* .gnu.linkonce.sb.*)
|
||||
*(.scommon)
|
||||
} > ram
|
||||
|
||||
.bss :
|
||||
{
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
*(COMMON)
|
||||
__bss_end__ = .;
|
||||
} > ram
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(.eh_*)
|
||||
}
|
||||
|
||||
__heap_base__ = __bss_end__;
|
||||
__heap_end__ = __ram_end__ - __stacks_total_size__;
|
||||
}
|
|
@ -0,0 +1,476 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file templates/chconf.h
|
||||
* @brief Configuration file template.
|
||||
* @addtogroup config
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _CHCONF_H_
|
||||
#define _CHCONF_H_
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Kernel parameters. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief System tick frequency.
|
||||
* @details Frequency of the system timer that drives the system ticks. This
|
||||
* setting also defines the system tick time unit.
|
||||
*/
|
||||
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
|
||||
#define CH_FREQUENCY 1000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Round robin interval.
|
||||
* @details This constant is the number of system ticks allowed for the
|
||||
* threads before preemption occurs. Setting this value to zero
|
||||
* disables the preemption for threads with equal priority and the
|
||||
* round robin becomes cooperative. Note that higher priority
|
||||
* threads can still preempt, the kernel is always preemptive.
|
||||
*
|
||||
* @note Disabling the round robin preemption makes the kernel more compact
|
||||
* and generally faster.
|
||||
*/
|
||||
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
|
||||
#define CH_TIME_QUANTUM 20
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Nested locks.
|
||||
* @details If enabled then the use of nested @p chSysLock() / @p chSysUnlock()
|
||||
* operations is allowed.<br>
|
||||
* For performance and code size reasons the recommended setting
|
||||
* is to leave this option disabled.<br>
|
||||
* You may use this option if you need to merge ChibiOS/RT with
|
||||
* external libraries that require nested lock/unlock operations.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_NESTED_LOCKS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Managed RAM size.
|
||||
* @details Size of the RAM area to be managed by the OS. If set to zero
|
||||
* then the whole available RAM is used. The core memory is made
|
||||
* available to the heap allocator and/or can be used directly through
|
||||
* the simplified core memory allocator.
|
||||
*
|
||||
* @note In order to let the OS manage the whole RAM the linker script must
|
||||
* provide the @p __heap_base__ and @p __heap_end__ symbols.
|
||||
* @note Requires @p CH_USE_COREMEM.
|
||||
*/
|
||||
#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
|
||||
#define CH_MEMCORE_SIZE 0
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Performance options. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief OS optimization.
|
||||
* @details If enabled then time efficient rather than space efficient code
|
||||
* is used when two possible implementations exist.
|
||||
*
|
||||
* @note This is not related to the compiler optimization options.
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
|
||||
#define CH_OPTIMIZE_SPEED TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Exotic optimization.
|
||||
* @details If defined then a CPU register is used as storage for the global
|
||||
* @p currp variable. Caching this variable in a register greatly
|
||||
* improves both space and time OS efficiency. A side effect is that
|
||||
* one less register has to be saved during the context switch
|
||||
* resulting in lower RAM usage and faster context switch.
|
||||
*
|
||||
* @note This option is only usable with the GCC compiler and is only useful
|
||||
* on processors with many registers like ARM cores.
|
||||
* @note If this option is enabled then ALL the libraries linked to the
|
||||
* ChibiOS/RT code <b>must</b> be recompiled with the GCC option @p
|
||||
* -ffixed-@<reg@>.
|
||||
* @note This option must be enabled in the Makefile, it is listed here for
|
||||
* documentation only.
|
||||
*/
|
||||
#if defined(__DOXYGEN__)
|
||||
#define CH_CURRP_REGISTER_CACHE "reg"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Subsystem options. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Threads registry APIs.
|
||||
* @details If enabled then the registry APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
|
||||
#define CH_USE_REGISTRY TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Threads synchronization APIs.
|
||||
* @details If enabled then the @p chThdWait() function is included in
|
||||
* the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
|
||||
#define CH_USE_WAITEXIT TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Semaphores APIs.
|
||||
* @details If enabled then the Semaphores APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_SEMAPHORES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Semaphores queuing mode.
|
||||
* @details If enabled then the threads are enqueued on semaphores by
|
||||
* priority rather than in FIFO order.
|
||||
*
|
||||
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define CH_USE_SEMAPHORES_PRIORITY FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Atomic semaphore API.
|
||||
* @details If enabled then the semaphores the @p chSemSignalWait() API
|
||||
* is included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
|
||||
#define CH_USE_SEMSW TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mutexes APIs.
|
||||
* @details If enabled then the mutexes APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MUTEXES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Conditional Variables APIs.
|
||||
* @details If enabled then the conditional variables APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_MUTEXES.
|
||||
*/
|
||||
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_CONDVARS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Conditional Variables APIs with timeout.
|
||||
* @details If enabled then the conditional variables APIs with timeout
|
||||
* specification are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_CONDVARS.
|
||||
*/
|
||||
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
|
||||
#define CH_USE_CONDVARS_TIMEOUT TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs.
|
||||
* @details If enabled then the event flags APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_EVENTS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs with timeout.
|
||||
* @details If enabled then the events APIs with timeout specification
|
||||
* are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_EVENTS.
|
||||
*/
|
||||
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
|
||||
#define CH_USE_EVENTS_TIMEOUT TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages APIs.
|
||||
* @details If enabled then the synchronous messages APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MESSAGES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages queuing mode.
|
||||
* @details If enabled then messages are served by priority rather than in
|
||||
* FIFO order.
|
||||
*
|
||||
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||
* @note Requires @p CH_USE_MESSAGES.
|
||||
*/
|
||||
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MESSAGES_PRIORITY FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mailboxes APIs.
|
||||
* @details If enabled then the asynchronous messages (mailboxes) APIs are
|
||||
* included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MAILBOXES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief I/O Queues APIs.
|
||||
* @details If enabled then the I/O queues APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_QUEUES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Core Memory Manager APIs.
|
||||
* @details If enabled then the core memory manager APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MEMCORE TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Heap Allocator APIs.
|
||||
* @details If enabled then the memory heap allocator APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_COREMEM and either @p CH_USE_MUTEXES or
|
||||
* @p CH_USE_SEMAPHORES.
|
||||
* @note Mutexes are recommended.
|
||||
*/
|
||||
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
|
||||
#define CH_USE_HEAP TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief C-runtime allocator.
|
||||
* @details If enabled the the heap allocator APIs just wrap the C-runtime
|
||||
* @p malloc() and @p free() functions.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
* @note Requires @p CH_USE_HEAP.
|
||||
* @note The C-runtime may or may not require @p CH_USE_COREMEM, see the
|
||||
* appropriate documentation.
|
||||
*/
|
||||
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MALLOC_HEAP FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Memory Pools Allocator APIs.
|
||||
* @details If enabled then the memory pools allocator APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MEMPOOLS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Dynamic Threads APIs.
|
||||
* @details If enabled then the dynamic threads creation APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_WAITEXIT.
|
||||
*/
|
||||
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
|
||||
#define CH_USE_DYNAMIC TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Debug options. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Debug option, parameters checks.
|
||||
* @details If enabled then the checks on the API functions input
|
||||
* parameters are activated.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_ENABLE_CHECKS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, consistency checks.
|
||||
* @details If enabled then all the assertions in the kernel code are
|
||||
* activated. This includes consistency checks inside the kernel,
|
||||
* runtime anomalies and port-defined checks.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_ENABLE_ASSERTS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, trace buffer.
|
||||
* @details If enabled then the context switch circular trace buffer is
|
||||
* activated.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_ENABLE_TRACE FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, stack checks.
|
||||
* @details If enabled then a runtime stack check is performed.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
* @note The stack check is performed in a architecture/port dependent way. It
|
||||
* may not be implemented or some ports.
|
||||
* @note The default failure mode is to halt the system with the global
|
||||
* @p panic_msg variable set to @p NULL.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_ENABLE_STACK_CHECK FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, stacks initialization.
|
||||
* @details If enabled then the threads working area is filled with a byte
|
||||
* value when a thread is created. This can be useful for the
|
||||
* runtime measurement of the used stack.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_FILL_THREADS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, threads profiling.
|
||||
* @details If enabled then a field is added to the @p Thread structure that
|
||||
* counts the system ticks occurred while executing the thread.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note This debug option is defaulted to TRUE because it is required by
|
||||
* some test cases into the test suite.
|
||||
*/
|
||||
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_THREADS_PROFILING TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Kernel hooks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Threads descriptor structure hook.
|
||||
* @details User fields added to the end of the @p Thread structure.
|
||||
*/
|
||||
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
|
||||
#define THREAD_EXT_FIELDS \
|
||||
/* Add threads custom fields here.*/
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Threads initialization hook.
|
||||
* @details User initialization code added to the @p chThdInit() API.
|
||||
*
|
||||
* @note It is invoked from within @p chThdInit() and implicitily from all
|
||||
* the threads creation APIs.
|
||||
*/
|
||||
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
|
||||
#define THREAD_EXT_INIT(tp) { \
|
||||
/* Add threads initialization code here.*/ \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Threads finalization hook.
|
||||
* @details User finalization code added to the @p chThdExit() API.
|
||||
*
|
||||
* @note It is inserted into lock zone.
|
||||
* @note It is also invoked when the threads simply return in order to
|
||||
* terminate.
|
||||
*/
|
||||
#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
|
||||
#define THREAD_EXT_EXIT(tp) { \
|
||||
/* Add threads finalization code here.*/ \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Idle Loop hook.
|
||||
* @details This hook is continuously invoked by the idle thread loop.
|
||||
*/
|
||||
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
|
||||
#define IDLE_LOOP_HOOK() { \
|
||||
/* Idle loop code here.*/ \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CHCONF_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file templates/halconf.h
|
||||
* @brief HAL configuration header.
|
||||
* @addtogroup HAL_CONF
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* HAL configuration file, this file allows to enable or disable the various
|
||||
* device drivers from your application. You may also use this file in order
|
||||
* to override the device drivers default settings.
|
||||
*/
|
||||
|
||||
#ifndef _HALCONF_H_
|
||||
#define _HALCONF_H_
|
||||
|
||||
/*
|
||||
* Uncomment the following line in order to include a mcu-related
|
||||
* settings file. This file can be used to include platform specific
|
||||
* header files or to override the low level drivers settings.
|
||||
*/
|
||||
/*#include "mcuconf.h"*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* PAL driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the PAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PAL FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ADC driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the ADC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_ADC FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* CAN driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the CAN subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_CAN FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* MAC driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the MAC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MAC FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* PWM driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the PWM subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PWM FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* SERIAL driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the SERIAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SERIAL TRUE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SERIAL settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SERIAL_DEFAULT_BITRATE 38400*/
|
||||
/*#define SERIAL_BUFFERS_SIZE 64*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* SPI driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SPI FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SPI_USE_MUTUAL_EXCLUSION TRUE*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* MMC_SPI driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the MMC_SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MMC_SPI FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default MMC_SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define MMC_SECTOR_SIZE 512*/
|
||||
/*#define MMC_NICE_WAITING TRUE*/
|
||||
/*#define MMC_POLLING_INTERVAL 10*/
|
||||
/*#define MMC_POLLING_DELAY 10*/
|
||||
|
||||
#endif /* _HALCONF_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "test.h"
|
||||
#include "memstreams.h"
|
||||
|
||||
int a = 1234;
|
||||
uint8_t report_buffer[8192];
|
||||
|
||||
/*
|
||||
* LEDs blinker thread, times are in milliseconds.
|
||||
*/
|
||||
static WORKING_AREA(waThread1, 128);
|
||||
static msg_t Thread1(void *arg) {
|
||||
|
||||
(void)arg;
|
||||
|
||||
SIU.GPDO[GPIO_LED1].R = 1;
|
||||
SIU.GPDO[GPIO_LED2].R = 1;
|
||||
SIU.GPDO[GPIO_LED3].R = 1;
|
||||
SIU.GPDO[GPIO_LED4].R = 1;
|
||||
|
||||
while (TRUE) {
|
||||
SIU.GPDO[GPIO_LED1].R = 0;
|
||||
chThdSleepMilliseconds(100);
|
||||
SIU.GPDO[GPIO_LED2].R = 0;
|
||||
chThdSleepMilliseconds(100);
|
||||
SIU.GPDO[GPIO_LED3].R = 0;
|
||||
chThdSleepMilliseconds(100);
|
||||
SIU.GPDO[GPIO_LED4].R = 0;
|
||||
chThdSleepMilliseconds(100);
|
||||
SIU.GPDO[GPIO_LED1].R = 1;
|
||||
chThdSleepMilliseconds(100);
|
||||
SIU.GPDO[GPIO_LED2].R = 1;
|
||||
chThdSleepMilliseconds(100);
|
||||
SIU.GPDO[GPIO_LED3].R = 1;
|
||||
chThdSleepMilliseconds(100);
|
||||
SIU.GPDO[GPIO_LED4].R = 1;
|
||||
chThdSleepMilliseconds(300);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Entry point, note, the main() function is already a thread in the system
|
||||
* on entry.
|
||||
*/
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
/*
|
||||
* Activates the serial driver 1 using the driver default configuration.
|
||||
*/
|
||||
sdStart(&SD1, NULL);
|
||||
|
||||
/*
|
||||
* Creates the blinker thread.
|
||||
*/
|
||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
||||
|
||||
/*
|
||||
* Normal main() thread activity.
|
||||
*/
|
||||
while (TRUE) {
|
||||
if (SIU.GPDI[GPIO_BUTTON1].B.PDI) {
|
||||
volatile msg_t result;
|
||||
#if 0
|
||||
MemoryStream report;
|
||||
|
||||
msObjectInit(&report, report_buffer, sizeof(report_buffer), 0);
|
||||
result = TestThread(&report);
|
||||
#else
|
||||
result = TestThread(&SD1);
|
||||
#endif
|
||||
}
|
||||
chThdSleepMilliseconds(1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
***************************************************************************
|
||||
Options: -O2 -fomit-frame-pointer -msdata=none -falign-functions=16
|
||||
Settings: SYSCLK=80, optimal wait states, prefetching enabled
|
||||
***************************************************************************
|
||||
|
||||
*** ChibiOS/RT test suite
|
||||
***
|
||||
*** Kernel: 1.5.1unstable
|
||||
*** Architecture: PPC E200Zx
|
||||
*** GCC Version: 4.4.1
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 1.1 (Threads, enqueuing test #1)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 1.2 (Threads, enqueuing test #2)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 1.3 (Threads, priority change)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 1.4 (Threads, delays)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 2.1 (Semaphores, enqueuing)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 2.2 (Semaphores, timeout)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 2.3 (Semaphores, atomic signal-wait)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.1 (Mutexes, priority enqueuing test)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.2 (Mutexes, priority inheritance, simple case)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.3 (Mutexes, priority inheritance, complex case)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.4 (Mutexes, priority return)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.5 (Mutexes, status)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.6 (CondVar, signal test)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.7 (CondVar, broadcast test)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 3.8 (CondVar, boost test)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 4.1 (Messages, loop)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 5.1 (Mailboxes, queuing and timeouts)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 6.1 (Events, registration and dispatch)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 6.2 (Events, wait and broadcast)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 6.3 (Events, timeouts)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 7.1 (Heap, allocation and fragmentation test)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 8.1 (Memory Pools, queue/dequeue)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 9.1 (Dynamic APIs, threads creation from heap)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 9.2 (Dynamic APIs, threads creation from memory pool)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 10.1 (Queues, input queues)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 10.2 (Queues, output queues)
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.1 (Benchmark, messages #1)
|
||||
--- Score : 276305 msgs/S, 552610 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.2 (Benchmark, messages #2)
|
||||
--- Score : 224302 msgs/S, 448604 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.3 (Benchmark, messages #3)
|
||||
--- Score : 224302 msgs/S, 448604 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.4 (Benchmark, context switch)
|
||||
--- Score : 878728 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.5 (Benchmark, threads, full cycle)
|
||||
--- Score : 180662 threads/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.6 (Benchmark, threads, create only)
|
||||
--- Score : 259260 threads/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.7 (Benchmark, mass reschedulation, 5 threads)
|
||||
--- Score : 73119 reschedulations/S, 438714 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.8 (Benchmark, round robin context switching)
|
||||
--- Score : 654412 reschedulations/S, 654412 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
|
||||
--- Score : 617488 bytes/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
|
||||
--- Score : 1132448 timers/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
|
||||
--- Score : 1027012 wait+signal/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
|
||||
--- Score : 871856 lock+unlock/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.13 (Benchmark, RAM footprint)
|
||||
--- System: 760 bytes
|
||||
--- Thread: 68 bytes
|
||||
--- Timer : 20 bytes
|
||||
--- Semaph: 12 bytes
|
||||
--- EventS: 4 bytes
|
||||
--- EventL: 12 bytes
|
||||
--- Mutex : 16 bytes
|
||||
--- CondV.: 8 bytes
|
||||
--- Queue : 32 bytes
|
||||
--- MailB.: 40 bytes
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
Final result: SUCCESS
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file SPC563/hal_lld.c
|
||||
* @brief SPC563 HAL subsystem low level driver source.
|
||||
*
|
||||
* @addtogroup SPC563_HAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver interrupt handlers. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Low level HAL driver initialization.
|
||||
*/
|
||||
void hal_lld_init(void) {
|
||||
extern void _vectors(void);
|
||||
uint32_t n;
|
||||
|
||||
/* Enables the branch prediction, clears and enables the BTB into the
|
||||
BUCSR special register (1013).*/
|
||||
asm volatile ("li %%r3, 0x0201 \t\n"
|
||||
"mtspr 1013, %%r3": : : "r3");
|
||||
|
||||
/* FLASH wait states and prefetching setup.*/
|
||||
CFLASH0.BIUCR.R = SPC563_FLASH_BIUCR | SPC563_FLASH_WS;
|
||||
CFLASH0.BIUCR2.R = 0;
|
||||
CFLASH0.PFCR3.R = 0;
|
||||
|
||||
/* Optimal crossbar settings. The DMA priority is placed above the CPU
|
||||
priority in order to not starve I/O activities while the CPU is
|
||||
excuting tight loops (FLASH and SRAM slave ports only).
|
||||
The SRAM is parked on the load/store port, for some unknown reason it
|
||||
is defaulted on the instructions port and this kills performance.*/
|
||||
XBAR.SGPCR3.B.PARK = 4; /* RAM slave on load/store port.*/
|
||||
XBAR.MPR0.R = 0x00030201; /* Flash slave port priorities:
|
||||
eDMA (1): 0 (highest)
|
||||
Core Instructions (0): 1
|
||||
Undocumented (2): 2
|
||||
Core Data (4): 3 */
|
||||
XBAR.MPR3.R = 0x00030201; /* SRAM slave port priorities:
|
||||
eDMA (1): 0 (highest)
|
||||
Core Instructions (0): 1
|
||||
Undocumented (2): 2
|
||||
Core Data (4): 3 */
|
||||
|
||||
/* Downcounter timer initialized for system tick use, TB enabled for debug
|
||||
and measurements.*/
|
||||
n = SPC563_SYSCLK / CH_FREQUENCY;
|
||||
asm volatile ("li %%r3, 0 \t\n"
|
||||
"mtspr 284, %%r3 \t\n" /* Clear TBL register. */
|
||||
"mtspr 285, %%r3 \t\n" /* Clear TBU register. */
|
||||
"mtspr 22, %[n] \t\n" /* Init. DEC register. */
|
||||
"mtspr 54, %[n] \t\n" /* Init. DECAR register.*/
|
||||
"li %%r3, 0x4000 \t\n" /* TBEN bit. */
|
||||
"mtspr 1008, %%r3 \t\n" /* HID0 register. */
|
||||
"lis %%r3, 0x0440 \t\n" /* DIE ARE bits. */
|
||||
"mtspr 340, %%r3" /* TCR register. */
|
||||
: : [n] "r" (n) : "r3");
|
||||
|
||||
/* INTC initialization, software vector mode, 4 bytes vectors, starting
|
||||
at priority 0.*/
|
||||
INTC.MCR.R = 0;
|
||||
INTC.CPR.R = 0;
|
||||
INTC.IACKR.R = (uint32_t)_vectors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPC563 clocks and PLL initialization.
|
||||
* @note All the involved constants come from the file @p board.h and
|
||||
* @p hal_lld.h
|
||||
*/
|
||||
void spc563_clock_init(void) {
|
||||
|
||||
/* PLL activation.*/
|
||||
FMPLL.ESYNCR1.B.EMODE = 1;
|
||||
FMPLL.ESYNCR1.B.CLKCFG &= 1; /* Bypass mode, PLL off.*/
|
||||
FMPLL.ESYNCR1.B.CLKCFG |= 2; /* PLL on. */
|
||||
FMPLL.ESYNCR1.B.EPREDIV = SPC563_CLK_PREDIV;
|
||||
FMPLL.ESYNCR1.B.EMFD = SPC563_CLK_MFD;
|
||||
FMPLL.ESYNCR2.B.ERFD = SPC563_CLK_RFD;
|
||||
while (!FMPLL.SYNSR.B.LOCK)
|
||||
;
|
||||
FMPLL.ESYNCR1.B.CLKCFG |= 4; /* Clock from the PLL. */
|
||||
}
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file SPC563/hal_lld.h
|
||||
* @brief SPC563 HAL subsystem low level driver header.
|
||||
*
|
||||
* @addtogroup SPC563_HAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _HAL_LLD_H_
|
||||
#define _HAL_LLD_H_
|
||||
|
||||
#include "mpc563m.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#define RFD_DIV2 0 /**< Divide VCO frequency by 2. */
|
||||
#define RFD_DIV4 1 /**< Divide VCO frequency by 4. */
|
||||
#define RFD_DIV8 2 /**< Divide VCO frequency by 8. */
|
||||
#define RFD_DIV16 3 /**< Divide VCO frequency by 16.*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Clock bypass.
|
||||
* @note If set to @p TRUE then the PLL is not started and initialized, the
|
||||
* external clock is used as-is and the other clock-related settings
|
||||
* are ignored.
|
||||
*/
|
||||
#if !defined(SPC563_CLK_BYPASS) || defined(__DOXYGEN__)
|
||||
#define SPC563_CLK_BYPASS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Disables the overclock checks.
|
||||
*/
|
||||
#if !defined(SPC563_ALLOW_OVERCLOCK) || defined(__DOXYGEN__)
|
||||
#define SPC563_ALLOW_OVERCLOCK FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief External clock pre-divider.
|
||||
* @note Must be in range 0...14.
|
||||
* @note The effective divider factor is this value plus one.
|
||||
*/
|
||||
#if !defined(SPC563_CLK_PREDIV) || defined(__DOXYGEN__)
|
||||
#define SPC563_CLK_PREDIV 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Multiplication factor divider.
|
||||
* @note Must be in range 32...96.
|
||||
*/
|
||||
#if !defined(SPC563_CLK_MFD) || defined(__DOXYGEN__)
|
||||
#define SPC563_CLK_MFD 40
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Reduced frequency divider.
|
||||
*/
|
||||
#if !defined(SPC563_CLK_RFD) || defined(__DOXYGEN__)
|
||||
#define SPC563_CLK_RFD RFD_DIV4
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Flash buffer and prefetching settings.
|
||||
* @note Please refer to the SPC563M64 reference manual about the meaning
|
||||
* of the following bits, if in doubt DO NOT MODIFY IT.
|
||||
* @note Do not specify the APC, WWSC, RWSC bits in this value because
|
||||
* those are calculated from the system clock and ORed with this
|
||||
* value.
|
||||
*/
|
||||
#if !defined(SPC563_FLASH_BIUCR) || defined(__DOXYGEN__)
|
||||
#define SPC563_FLASH_BIUCR (0x01110053 & 0xFFFF00FF)
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if (SPC563_CLK_PREDIV < 0) || (SPC563_CLK_PREDIV > 14)
|
||||
#error "invalid SPC563_CLK_PREDIV value specified"
|
||||
#endif
|
||||
|
||||
#if (SPC563_CLK_MFD < 32) || (SPC563_CLK_MFD > 96)
|
||||
#error "invalid SPC563_CLK_MFD value specified"
|
||||
#endif
|
||||
|
||||
#if (SPC563_CLK_RFD != RFD_DIV2) && (SPC563_CLK_RFD != RFD_DIV4) && \
|
||||
(SPC563_CLK_RFD != RFD_DIV8) && (SPC563_CLK_RFD != RFD_DIV16)
|
||||
#error "invalid SPC563_CLK_RFD value specified"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PLL output clock.
|
||||
*/
|
||||
#define SPC563_PLLCLK ((EXTCLK / (SPC563_CLK_PREDIV + 1)) * SPC563_CLK_MFD)
|
||||
|
||||
#if (SPC563_PLLCLK < 256000000) || (SPC563_PLLCLK > 512000000)
|
||||
#error "VCO frequency out of the acceptable range (256...512)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PLL output clock.
|
||||
*/
|
||||
#if !SPC563_CLK_BYPASS || defined(__DOXYGEN__)
|
||||
#define SPC563_SYSCLK (SPC563_PLLCLK / (1 << (SPC563_CLK_RFD + 1)))
|
||||
#else
|
||||
#define SPC563_SYSCLK EXTCLK
|
||||
#endif
|
||||
|
||||
#if (SPC563_SYSCLK > 80000000) && !SPC563_ALLOW_OVERCLOCK
|
||||
#error "System clock above maximum rated frequency (80MHz)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Flash wait states are a function of the system clock.
|
||||
*/
|
||||
#if (SPC563_SYSCLK <= 30000000) || defined(__DOXYGEN__)
|
||||
#define SPC563_FLASH_WS 0x00000800 /* APC=0, RWSC=0, WWSC=1. */
|
||||
#elif SPC563_SYSCLK <= 60000000
|
||||
#define SPC563_FLASH_WS 0x00002900 /* APC=1, RWSC=1, WWSC=1. */
|
||||
#else
|
||||
#define SPC563_FLASH_WS 0x00004A00 /* APC=2, RWSC=2, WWSC=1. */
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void hal_lld_init(void);
|
||||
void spc563_clock_init(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HAL_LLD_H_ */
|
||||
|
||||
/** @} */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,6 @@
|
|||
# List of all the SPC563 platform files.
|
||||
PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/SPC563/hal_lld.c \
|
||||
${CHIBIOS}/os/hal/platforms/SPC563/serial_lld.c
|
||||
|
||||
# Required include directories
|
||||
PLATFORMINC = ${CHIBIOS}/os/hal/platforms/SPC563
|
|
@ -0,0 +1,291 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file SPC563/serial_lld.c
|
||||
* @brief SPC563 low level serial driver code.
|
||||
*
|
||||
* @addtogroup SPC563_SERIAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief eSCI-A serial driver identifier.
|
||||
*/
|
||||
#if USE_SPC563_ESCIA || defined(__DOXYGEN__)
|
||||
SerialDriver SD1;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief eSCI-B serial driver identifier.
|
||||
*/
|
||||
#if USE_SPC563_ESCIB || defined(__DOXYGEN__)
|
||||
SerialDriver SD2;
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Driver default configuration.
|
||||
*/
|
||||
static const SerialConfig default_config = {
|
||||
SERIAL_DEFAULT_BITRATE,
|
||||
SC_MODE_NORMAL | SC_MODE_PARITY_NONE
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief eSCI initialization.
|
||||
* @details This function must be invoked with interrupts disabled.
|
||||
*
|
||||
* @param[in] sdp pointer to a @p SerialDriver object
|
||||
*/
|
||||
static void esci_init(SerialDriver *sdp) {
|
||||
volatile struct ESCI_tag *escip = sdp->escip;
|
||||
uint8_t mode = sdp->config->sc_mode;
|
||||
|
||||
escip->CR2.R = 0; /* MDIS off. */
|
||||
escip->CR1.R = 0;
|
||||
escip->LCR.R = 0;
|
||||
escip->CR1.B.SBR = SPC563_SYSCLK / (16 * sdp->config->sc_speed);
|
||||
if (mode & SC_MODE_LOOPBACK)
|
||||
escip->CR1.B.LOOPS = 1;
|
||||
switch (mode & SC_MODE_PARITY) {
|
||||
case SC_MODE_PARITY_ODD:
|
||||
escip->CR1.B.PT = 1;
|
||||
case SC_MODE_PARITY_EVEN:
|
||||
escip->CR1.B.PE = 1;
|
||||
escip->CR1.B.M = 1; /* Makes it 8 bits data + 1 bit parity. */
|
||||
default:
|
||||
;
|
||||
}
|
||||
escip->LPR.R = 0;
|
||||
escip->CR1.R |= 0x0000002C; /* RIE, TE, RE to 1. */
|
||||
escip->CR2.R |= 0x000F; /* ORIE, NFIE, FEIE, PFIE to 1. */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief eSCI de-initialization.
|
||||
* @details This function must be invoked with interrupts disabled.
|
||||
*
|
||||
* @param[in] escip pointer to an eSCI I/O block
|
||||
*/
|
||||
static void esci_deinit(volatile struct ESCI_tag *escip) {
|
||||
|
||||
escip->LPR.R = 0;
|
||||
escip->SR.R = 0xFFFFFFFF;
|
||||
escip->CR1.R = 0;
|
||||
escip->CR2.R = 0x8000; /* MDIS on. */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Error handling routine.
|
||||
*
|
||||
* @param[in] sdp pointer to a @p SerialDriver object
|
||||
* @param[in] sr eSCI SR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, uint32_t sr) {
|
||||
sdflags_t sts = 0;
|
||||
|
||||
if (sr & 0x08000000)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
if (sr & 0x04000000)
|
||||
sts |= SD_NOISE_ERROR;
|
||||
if (sr & 0x02000000)
|
||||
sts |= SD_FRAMING_ERROR;
|
||||
if (sr & 0x01000000)
|
||||
sts |= SD_PARITY_ERROR;
|
||||
/* if (sr & 0x00000000)
|
||||
sts |= SD_BREAK_DETECTED;*/
|
||||
chSysLockFromIsr();
|
||||
sdAddFlagsI(sdp, sts);
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Common IRQ handler.
|
||||
*
|
||||
* @param[in] sdp pointer to a @p SerialDriver object
|
||||
*/
|
||||
static void serve_interrupt(SerialDriver *sdp) {
|
||||
volatile struct ESCI_tag *escip = sdp->escip;
|
||||
|
||||
uint32_t sr = escip->SR.R;
|
||||
escip->SR.R = 0x3FFFFFFF; /* Does not clear TDRE | TC.*/
|
||||
if (sr & 0x0F000000) /* OR | NF | FE | PF. */
|
||||
set_error(sdp, sr);
|
||||
if (sr & 0x20000000) { /* RDRF. */
|
||||
chSysLockFromIsr();
|
||||
sdIncomingDataI(sdp, escip->DR.B.D);
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
if (escip->CR1.B.TIE && (sr & 0x80000000)) { /* TDRE. */
|
||||
msg_t b;
|
||||
chSysLockFromIsr();
|
||||
b = chOQGetI(&sdp->oqueue);
|
||||
if (b < Q_OK) {
|
||||
chEvtBroadcastI(&sdp->oevent);
|
||||
escip->CR1.B.TIE = 0;
|
||||
}
|
||||
else {
|
||||
ESCI_A.SR.B.TDRE = 1;
|
||||
escip->DR.R = (uint16_t)b;
|
||||
}
|
||||
chSysUnlockFromIsr();
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_SPC563_ESCIA || defined(__DOXYGEN__)
|
||||
static void notify1(void) {
|
||||
|
||||
if (ESCI_A.SR.B.TDRE) {
|
||||
msg_t b = sdRequestDataI(&SD1);
|
||||
if (b != Q_EMPTY) {
|
||||
ESCI_A.SR.B.TDRE = 1;
|
||||
ESCI_A.CR1.B.TIE = 1;
|
||||
ESCI_A.DR.R = (uint16_t)b;
|
||||
}
|
||||
}
|
||||
/* if (!ESCI_A.CR1.B.TIE) {
|
||||
msg_t b = sdRequestDataI(&SD1);
|
||||
if (b != Q_EMPTY) {
|
||||
ESCI_A.CR1.B.TIE = 1;
|
||||
ESCI_A.DR.R = (uint16_t)b;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USE_SPC563_ESCIB || defined(__DOXYGEN__)
|
||||
static void notify2(void) {
|
||||
|
||||
if (ESCI_B.SR.B.TDRE) {
|
||||
msg_t b = sdRequestDataI(&SD2);
|
||||
if (b != Q_EMPTY) {
|
||||
ESCI_B.SR.B.TDRE = 1;
|
||||
ESCI_B.CR1.B.TIE = 1;
|
||||
ESCI_B.DR.R = (uint16_t)b;
|
||||
}
|
||||
}
|
||||
/* if (!ESCI_B.CR1.B.TIE) {
|
||||
msg_t b = sdRequestDataI(&SD2);
|
||||
if (b != Q_EMPTY) {
|
||||
ESCI_B.CR1.B.TIE = 1;
|
||||
ESCI_B.DR.R = (uint16_t)b;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver interrupt handlers. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if USE_SPC563_ESCIA || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief eSCI-A interrupt handler.
|
||||
*/
|
||||
CH_IRQ_HANDLER(vector146) {
|
||||
|
||||
CH_IRQ_PROLOGUE();
|
||||
|
||||
serve_interrupt(&SD1);
|
||||
|
||||
CH_IRQ_EPILOGUE();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USE_SPC563_ESCIB || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief eSCI-B interrupt handler.
|
||||
*/
|
||||
CH_IRQ_HANDLER(vector149) {
|
||||
|
||||
CH_IRQ_PROLOGUE();
|
||||
|
||||
serve_interrupt(&SD2);
|
||||
|
||||
CH_IRQ_EPILOGUE();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Low level serial driver initialization.
|
||||
*/
|
||||
void sd_lld_init(void) {
|
||||
|
||||
#if USE_SPC563_ESCIA
|
||||
sdObjectInit(&SD1, NULL, notify1);
|
||||
SD1.escip = &ESCI_A;
|
||||
ESCI_A.CR2.R = 0x8000; /* MDIS ON. */
|
||||
INTC.PSR[146].R = SPC563_ESCIA_PRIORITY;
|
||||
#endif
|
||||
|
||||
#if USE_SPC563_ESCIB
|
||||
sdObjectInit(&SD2, NULL, notify2);
|
||||
SD2.escip = &ESCI_B;
|
||||
ESCI_B.CR2.R = 0x8000; /* MDIS ON. */
|
||||
INTC.PSR[149].R = SPC563_ESCIB_PRIORITY;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Low level serial driver configuration and (re)start.
|
||||
*
|
||||
* @param[in] sdp pointer to a @p SerialDriver object
|
||||
*/
|
||||
void sd_lld_start(SerialDriver *sdp) {
|
||||
|
||||
if (sdp->config == NULL)
|
||||
sdp->config = &default_config;
|
||||
esci_init(sdp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Low level serial driver stop.
|
||||
*
|
||||
* @param[in] sdp pointer to a @p SerialDriver object
|
||||
*/
|
||||
void sd_lld_stop(SerialDriver *sdp) {
|
||||
|
||||
if (sdp->state == SD_READY)
|
||||
esci_deinit(sdp->escip);
|
||||
}
|
||||
|
||||
#endif /* CH_HAL_USE_SERIAL */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file SPC563/serial_lld.h
|
||||
* @brief SPC563 low level serial driver header.
|
||||
*
|
||||
* @addtogroup SPC563_SERIAL
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _SERIAL_LLD_H_
|
||||
#define _SERIAL_LLD_H_
|
||||
|
||||
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#define SC_MODE_PARITY 0x03 /**< @brief Parity field mask. */
|
||||
#define SC_MODE_PARITY_NONE 0x00 /**< @brief No parity. */
|
||||
#define SC_MODE_PARITY_EVEN 0x01 /**< @brief Even parity. */
|
||||
#define SC_MODE_PARITY_ODD 0x02 /**< @brief Odd parity. */
|
||||
|
||||
#define SC_MODE_NORMAL 0x00 /**< @brief Normal operations. */
|
||||
#define SC_MODE_LOOPBACK 0x80 /**< @brief Internal loopback. */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief eSCI-A driver enable switch.
|
||||
* @details If set to @p TRUE the support for eSCI-A is included.
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(USE_SPC563_ESCIA) || defined(__DOXYGEN__)
|
||||
#define USE_SPC563_ESCIA TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief eSCI-B driver enable switch.
|
||||
* @details If set to @p TRUE the support for eSCI-B is included.
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(USE_SPC563_ESCIB) || defined(__DOXYGEN__)
|
||||
#define USE_SPC563_ESCIB TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief eSCI-A interrupt priority level setting.
|
||||
*/
|
||||
#if !defined(SPC563_ESCIA_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define SPC563_ESCIA_PRIORITY 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief eSCI-B interrupt priority level setting.
|
||||
*/
|
||||
#if !defined(SPC563_ESCIB_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define SPC563_ESCIB_PRIORITY 8
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Serial Driver condition flags type.
|
||||
*/
|
||||
typedef uint8_t sdflags_t;
|
||||
|
||||
/**
|
||||
* @brief Generic Serial Driver configuration structure.
|
||||
* @details An instance of this structure must be passed to @p sdStart()
|
||||
* in order to configure and start a serial driver operations.
|
||||
* @note This structure content is architecture dependent, each driver
|
||||
* implementation defines its own version and the custom static
|
||||
* initializers.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Bit rate.
|
||||
*/
|
||||
uint32_t sc_speed;
|
||||
/**
|
||||
* @brief Mode flags.
|
||||
*/
|
||||
uint8_t sc_mode;
|
||||
} SerialConfig;
|
||||
|
||||
/**
|
||||
* @brief @p SerialDriver specific data.
|
||||
*/
|
||||
#define _serial_driver_data \
|
||||
_base_asynchronous_channel_data \
|
||||
/* Driver state.*/ \
|
||||
sdstate_t state; \
|
||||
/* Current configuration data.*/ \
|
||||
const SerialConfig *config; \
|
||||
/* Input queue.*/ \
|
||||
InputQueue iqueue; \
|
||||
/* Output queue.*/ \
|
||||
OutputQueue oqueue; \
|
||||
/* Status Change @p EventSource.*/ \
|
||||
EventSource sevent; \
|
||||
/* I/O driver status flags.*/ \
|
||||
sdflags_t flags; \
|
||||
/* Input circular buffer.*/ \
|
||||
uint8_t ib[SERIAL_BUFFERS_SIZE]; \
|
||||
/* Output circular buffer.*/ \
|
||||
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
|
||||
/* End of the mandatory fields.*/ \
|
||||
/* Pointer to the volatile eSCI registers block.*/ \
|
||||
volatile struct ESCI_tag *escip;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if USE_SPC563_ESCIA && !defined(__DOXYGEN__)
|
||||
extern SerialDriver SD1;
|
||||
#endif
|
||||
#if USE_SPC563_ESCIB && !defined(__DOXYGEN__)
|
||||
extern SerialDriver SD2;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void sd_lld_init(void);
|
||||
void sd_lld_start(SerialDriver *sdp);
|
||||
void sd_lld_stop(SerialDriver *sdp);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CH_HAL_USE_SERIAL */
|
||||
|
||||
#endif /* _SERIAL_LLD_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file SPC563/typedefs.h
|
||||
* @brief Dummy typedefs file.
|
||||
*/
|
||||
|
||||
#ifndef _TYPEDEFS_H_
|
||||
#define _TYPEDEFS_H_
|
||||
|
||||
#include "chtypes.h"
|
||||
|
||||
#endif /* _TYPEDEFS_H_ */
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file PPC/ivor.s
|
||||
* @brief PowerPC IVORx handlers.
|
||||
*
|
||||
* @addtogroup PPC_CORE
|
||||
* @{
|
||||
*/
|
||||
/** @cond never */
|
||||
|
||||
/*
|
||||
* INTC registers address.
|
||||
*/
|
||||
.equ INTC_IACKR, 0xfff48010
|
||||
.equ INTC_EOIR, 0xfff48018
|
||||
|
||||
.section .handlers
|
||||
|
||||
/*
|
||||
* IVOR10 handler (Book-E decrementer).
|
||||
*/
|
||||
.align 4
|
||||
.globl IVOR10
|
||||
IVOR10:
|
||||
/* Creation of the external stack frame (extctx structure).*/
|
||||
stwu %sp, -80(%sp) /* Size of the extctx structure.*/
|
||||
stw %r0, 32(%sp) /* Saves GPR0. */
|
||||
mfSRR0 %r0
|
||||
stw %r0, 8(%sp) /* Saves PC. */
|
||||
mfSRR1 %r0
|
||||
stw %r0, 12(%sp) /* Saves MSR. */
|
||||
mfCR %r0
|
||||
stw %r0, 16(%sp) /* Saves CR. */
|
||||
mfLR %r0
|
||||
stw %r0, 20(%sp) /* Saves LR. */
|
||||
mfCTR %r0
|
||||
stw %r0, 24(%sp) /* Saves CTR. */
|
||||
mfXER %r0
|
||||
stw %r0, 28(%sp) /* Saves XER. */
|
||||
stw %r3, 36(%sp) /* Saves GPR3...GPR12. */
|
||||
stw %r4, 40(%sp)
|
||||
stw %r5, 44(%sp)
|
||||
stw %r6, 48(%sp)
|
||||
stw %r7, 52(%sp)
|
||||
stw %r8, 56(%sp)
|
||||
stw %r9, 60(%sp)
|
||||
stw %r10, 64(%sp)
|
||||
stw %r11, 68(%sp)
|
||||
stw %r12, 72(%sp)
|
||||
|
||||
/* Reset DIE bit in TSR register.*/
|
||||
lis %r3, 0x0800 /* DIS bit mask. */
|
||||
mtspr 336, %r3 /* TSR register. */
|
||||
|
||||
/* System tick handler invokation.*/
|
||||
bl chSysTimerHandlerI
|
||||
bl chSchIsRescRequiredExI
|
||||
cmpli cr0, %r3, 0
|
||||
beq cr0, .ctxrestore
|
||||
bl chSchDoRescheduleI
|
||||
b .ctxrestore
|
||||
|
||||
/*
|
||||
* IVOR4 handler (Book-E external interrupt).
|
||||
*/
|
||||
.align 4
|
||||
.globl IVOR4
|
||||
IVOR4:
|
||||
/* Creation of the external stack frame (extctx structure).*/
|
||||
stwu %sp, -80(%sp) /* Size of the extctx structure.*/
|
||||
stw %r0, 32(%sp) /* Saves GPR0. */
|
||||
mfSRR0 %r0
|
||||
stw %r0, 8(%sp) /* Saves PC. */
|
||||
mfSRR1 %r0
|
||||
stw %r0, 12(%sp) /* Saves MSR. */
|
||||
mfCR %r0
|
||||
stw %r0, 16(%sp) /* Saves CR. */
|
||||
mfLR %r0
|
||||
stw %r0, 20(%sp) /* Saves LR. */
|
||||
mfCTR %r0
|
||||
stw %r0, 24(%sp) /* Saves CTR. */
|
||||
mfXER %r0
|
||||
stw %r0, 28(%sp) /* Saves XER. */
|
||||
stw %r3, 36(%sp) /* Saves GPR3...GPR12. */
|
||||
stw %r4, 40(%sp)
|
||||
stw %r5, 44(%sp)
|
||||
stw %r6, 48(%sp)
|
||||
stw %r7, 52(%sp)
|
||||
stw %r8, 56(%sp)
|
||||
stw %r9, 60(%sp)
|
||||
stw %r10, 64(%sp)
|
||||
stw %r11, 68(%sp)
|
||||
stw %r12, 72(%sp)
|
||||
|
||||
/* Software vector address from the INTC register.*/
|
||||
lis %r3, INTC_IACKR@h
|
||||
ori %r3, %r3, INTC_IACKR@l /* IACKR register address. */
|
||||
lwz %r3, 0(%r3) /* IACKR register value. */
|
||||
lwz %r3, 0(%r3)
|
||||
mtCTR %r3 /* Software handler address. */
|
||||
|
||||
#if PPC_USE_IRQ_PREEMPTION
|
||||
/* Allows preemption while executing the software handler.*/
|
||||
wrteei 1
|
||||
#endif
|
||||
|
||||
/* Exectes the software handler.*/
|
||||
bctrl
|
||||
|
||||
#if PPC_USE_IRQ_PREEMPTION
|
||||
/* Prevents preemption again.*/
|
||||
wrteei 0
|
||||
#endif
|
||||
|
||||
/* Informs the INTC that the interrupt has been served.*/
|
||||
mbar 0
|
||||
lis %r3, INTC_EOIR@h
|
||||
ori %r3, %r3, INTC_EOIR@l
|
||||
stw %r3, 0(%r3) /* Writing any value should do. */
|
||||
|
||||
/* Verifies if a reschedulation is required.*/
|
||||
bl chSchIsRescRequiredExI
|
||||
cmpli cr0, %r3, 0
|
||||
beq cr0, .ctxrestore
|
||||
bl chSchDoRescheduleI
|
||||
|
||||
/* Context restore.*/
|
||||
.ctxrestore:
|
||||
lwz %r3, 36(%sp) /* Restores GPR3...GPR12. */
|
||||
lwz %r4, 40(%sp)
|
||||
lwz %r5, 44(%sp)
|
||||
lwz %r6, 48(%sp)
|
||||
lwz %r7, 52(%sp)
|
||||
lwz %r8, 56(%sp)
|
||||
lwz %r9, 60(%sp)
|
||||
lwz %r10, 64(%sp)
|
||||
lwz %r11, 68(%sp)
|
||||
lwz %r12, 72(%sp)
|
||||
lwz %r0, 8(%sp)
|
||||
mtSRR0 %r0 /* Restores PC. */
|
||||
lwz %r0, 12(%sp)
|
||||
mtSRR1 %r0 /* Restores MSR. */
|
||||
lwz %r0, 16(%sp)
|
||||
mtCR %r0 /* Restores CR. */
|
||||
lwz %r0, 20(%sp)
|
||||
mtLR %r0 /* Restores LR. */
|
||||
lwz %r0, 24(%sp)
|
||||
mtCTR %r0 /* Restores CTR. */
|
||||
lwz %r0, 28(%sp)
|
||||
mtXER %r0 /* Restores XER. */
|
||||
lwz %r0, 32(%sp) /* Restores GPR0. */
|
||||
addi %sp, %sp, 80 /* Back to the previous frame. */
|
||||
rfi
|
||||
|
||||
/** @endcond */
|
||||
/** @} */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file PPC/chcore.c
|
||||
* @brief PowerPC architecture port code.
|
||||
*
|
||||
* @addtogroup PPC_CORE
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
|
||||
/**
|
||||
* @brief Halts the system.
|
||||
* @details This function is invoked by the operating system when an
|
||||
* unrecoverable error is detected (as example because a programming
|
||||
* error in the application code that triggers an assertion while
|
||||
* in debug mode).
|
||||
*/
|
||||
void port_halt(void) {
|
||||
|
||||
port_disable();
|
||||
while (TRUE) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Performs a context switch between two threads.
|
||||
* @details This is the most critical code in any port, this function
|
||||
* is responsible for the context switch between 2 threads.
|
||||
* @note The implementation of this code affects <b>directly</b> the context
|
||||
* switch performance so optimize here as much as you can.
|
||||
*
|
||||
* @param[in] otp the thread to be switched out
|
||||
* @param[in] ntp the thread to be switched in
|
||||
*/
|
||||
void port_switch(Thread *otp, Thread *ntp) {
|
||||
|
||||
(void)otp;
|
||||
(void)ntp;
|
||||
|
||||
asm ("subi %sp, %sp, 80"); /* Size of the intctx structure. */
|
||||
asm ("mflr %r0");
|
||||
asm ("stw %r0, 84(%sp)"); /* LR into the caller frame. */
|
||||
asm ("mfcr %r0");
|
||||
asm ("stw %r0, 0(%sp)"); /* CR. */
|
||||
asm ("stmw %r14, 4(%sp)"); /* GPR14...GPR31. */
|
||||
|
||||
asm ("stw %sp, 12(%r3)"); /* Store swapped-out stack. */
|
||||
asm ("lwz %sp, 12(%r4)"); /* Load swapped-in stack. */
|
||||
|
||||
asm ("lmw %r14, 4(%sp)"); /* GPR14...GPR31. */
|
||||
asm ("lwz %r0, 0(%sp)"); /* CR. */
|
||||
asm ("mtcr %r0");
|
||||
asm ("lwz %r0, 84(%sp)"); /* LR from the caller frame. */
|
||||
asm ("mtlr %r0");
|
||||
asm ("addi %sp, %sp, 80"); /* Size of the intctx structure. */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start a thread by invoking its work function.
|
||||
* @details If the work function returns @p chThdExit() is automatically
|
||||
* invoked.
|
||||
*/
|
||||
void _port_thread_start(void) {
|
||||
asm ("wrteei 1");
|
||||
asm ("mr %r3, %r31"); /* Thread parameter. */
|
||||
asm ("mtctr %r30");
|
||||
asm ("bctrl"); /* Invoke thread function. */
|
||||
asm ("bl chThdExit"); /* Thread termination on exit. */
|
||||
}
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,295 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file PPCE200Z/chcore.h
|
||||
* @brief PowerPC E200Zx architecture port macros and structures.
|
||||
*
|
||||
* @addtogroup PPCE200Z_CORE
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _CHCORE_H_
|
||||
#define _CHCORE_H_
|
||||
|
||||
/*
|
||||
* Port-related configuration parameters.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enables the use of the WFI ins.
|
||||
*/
|
||||
#ifndef ENABLE_WFI_IDLE
|
||||
#define ENABLE_WFI_IDLE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Unique macro for the implemented architecture.
|
||||
*/
|
||||
#define CH_ARCHITECTURE_PPCE200Z
|
||||
|
||||
/**
|
||||
* @brief Name of the implemented architecture.
|
||||
*/
|
||||
#define CH_ARCHITECTURE_NAME "PPC E200Zx"
|
||||
|
||||
/**
|
||||
* @brief Base type for stack alignment.
|
||||
* @details This type is used only for stack alignment reasons thus can be
|
||||
* anything from a char to a double.
|
||||
*/
|
||||
typedef uint64_t stkalign_t;
|
||||
|
||||
/**
|
||||
* @brief Generic PPC register.
|
||||
*/
|
||||
typedef void *regppc_t;
|
||||
|
||||
/**
|
||||
* @brief Mandatory part of a stack frame.
|
||||
*/
|
||||
struct eabi_frame {
|
||||
regppc_t slink; /**< Stack back link. */
|
||||
regppc_t shole; /**< Stack hole for LR storage. */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Interrupt saved context.
|
||||
* @details This structure represents the stack frame saved during a
|
||||
* preemption-capable interrupt handler.
|
||||
* @note R2 and R13 are not saved because those are assumed to be immutable
|
||||
* during the system life cycle.
|
||||
*/
|
||||
struct extctx {
|
||||
struct eabi_frame frame;
|
||||
/* Start of the e_stmvsrrw frame (offset 8).*/
|
||||
regppc_t pc;
|
||||
regppc_t msr;
|
||||
/* Start of the e_stmvsprw frame (offset 16).*/
|
||||
regppc_t cr;
|
||||
regppc_t lr;
|
||||
regppc_t ctr;
|
||||
regppc_t xer;
|
||||
/* Start of the e_stmvgprw frame (offset 32).*/
|
||||
regppc_t r0;
|
||||
regppc_t r3;
|
||||
regppc_t r4;
|
||||
regppc_t r5;
|
||||
regppc_t r6;
|
||||
regppc_t r7;
|
||||
regppc_t r8;
|
||||
regppc_t r9;
|
||||
regppc_t r10;
|
||||
regppc_t r11;
|
||||
regppc_t r12;
|
||||
regppc_t padding;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief System saved context.
|
||||
* @details This structure represents the inner stack frame during a context
|
||||
* switching.
|
||||
* @note R2 and R13 are not saved because those are assumed to be immutable
|
||||
* during the system life cycle.
|
||||
* @note LR is stored in the caller contex so it is not present in this
|
||||
* structure.
|
||||
*/
|
||||
struct intctx {
|
||||
regppc_t cr; /* Part of it is not volatile... */
|
||||
regppc_t r14;
|
||||
regppc_t r15;
|
||||
regppc_t r16;
|
||||
regppc_t r17;
|
||||
regppc_t r18;
|
||||
regppc_t r19;
|
||||
regppc_t r20;
|
||||
regppc_t r21;
|
||||
regppc_t r22;
|
||||
regppc_t r23;
|
||||
regppc_t r24;
|
||||
regppc_t r25;
|
||||
regppc_t r26;
|
||||
regppc_t r27;
|
||||
regppc_t r28;
|
||||
regppc_t r29;
|
||||
regppc_t r30;
|
||||
regppc_t r31;
|
||||
regppc_t padding;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Platform dependent part of the @p Thread structure.
|
||||
* @details This structure usually contains just the saved stack pointer
|
||||
* defined as a pointer to a @p intctx structure.
|
||||
*/
|
||||
struct context {
|
||||
struct intctx *sp;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Platform dependent part of the @p chThdInit() API.
|
||||
* @details This code usually setup the context switching frame represented
|
||||
* by an @p intctx structure.
|
||||
*/
|
||||
#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
|
||||
uint8_t *sp = (uint8_t *)workspace + wsize - sizeof(struct eabi_frame); \
|
||||
((struct eabi_frame *)sp)->slink = 0; \
|
||||
((struct eabi_frame *)sp)->shole = _port_thread_start; \
|
||||
tp->p_ctx.sp = (struct intctx *)(sp - sizeof(struct intctx)); \
|
||||
tp->p_ctx.sp->r31 = arg; \
|
||||
tp->p_ctx.sp->r30 = pf; \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stack size for the system idle thread.
|
||||
* @details This size depends on the idle thread implementation, usually
|
||||
* the idle thread should take no more space than those reserved
|
||||
* by @p INT_REQUIRED_STACK.
|
||||
*/
|
||||
#ifndef IDLE_THREAD_STACK_SIZE
|
||||
#define IDLE_THREAD_STACK_SIZE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Per-thread stack overhead for interrupts servicing.
|
||||
* @details This constant is used in the calculation of the correct working
|
||||
* area size.
|
||||
* This value can be zero on those architecture where there is a
|
||||
* separate interrupt stack and the stack space between @p intctx and
|
||||
* @p extctx is known to be zero.
|
||||
*/
|
||||
#ifndef INT_REQUIRED_STACK
|
||||
#define INT_REQUIRED_STACK 128
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enforces a correct alignment for a stack area size value.
|
||||
*/
|
||||
#define STACK_ALIGN(n) ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1)
|
||||
|
||||
/**
|
||||
* @brief Computes the thread working area global size.
|
||||
*/
|
||||
#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
|
||||
sizeof(struct intctx) + \
|
||||
sizeof(struct extctx) + \
|
||||
(n) + (INT_REQUIRED_STACK))
|
||||
|
||||
/**
|
||||
* @brief Static working area allocation.
|
||||
* @details This macro is used to allocate a static thread working area
|
||||
* aligned as both position and size.
|
||||
*/
|
||||
#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
|
||||
|
||||
/**
|
||||
* @brief IRQ prologue code.
|
||||
* @details This macro must be inserted at the start of all IRQ handlers
|
||||
* enabled to invoke system APIs.
|
||||
*/
|
||||
#define PORT_IRQ_PROLOGUE()
|
||||
|
||||
/**
|
||||
* @brief IRQ epilogue code.
|
||||
* @details This macro must be inserted at the end of all IRQ handlers
|
||||
* enabled to invoke system APIs.
|
||||
*/
|
||||
#define PORT_IRQ_EPILOGUE()
|
||||
|
||||
/**
|
||||
* @brief IRQ handler function declaration.
|
||||
* @note @p id can be a function name or a vector number depending on the
|
||||
* port implementation.
|
||||
*/
|
||||
#define PORT_IRQ_HANDLER(id) void id(void)
|
||||
|
||||
/**
|
||||
* @brief Kernel port layer initialization.
|
||||
* @details IVPR4 and IVPR10 initialization, INTC_IACKR_PRC0 initialization.
|
||||
*/
|
||||
#define port_init() { \
|
||||
asm volatile ("li %r3, IVOR4@l \t\n" \
|
||||
"mtIVOR4 %r3 \t\n" \
|
||||
"li %r3, IVOR10@l \t\n" \
|
||||
"mtIVOR10 %r3"); \
|
||||
}
|
||||
|
||||
/**
|
||||
* @details Implemented as global interrupt disable.
|
||||
*/
|
||||
#define port_lock() asm ("wrteei 0")
|
||||
|
||||
/**
|
||||
* @details Implemented as global interrupt enable.
|
||||
*/
|
||||
#define port_unlock() asm ("wrteei 1")
|
||||
|
||||
/**
|
||||
* @details Implemented as global interrupt disable.
|
||||
*/
|
||||
#define port_lock_from_isr() /*asm ("wrteei 0")*/
|
||||
|
||||
/**
|
||||
* @details Implemented as global interrupt enable.
|
||||
*/
|
||||
#define port_unlock_from_isr() /*asm ("wrteei 1")*/
|
||||
|
||||
/**
|
||||
* @details Implemented as global interrupt disable.
|
||||
*/
|
||||
#define port_disable() asm ("wrteei 0")
|
||||
|
||||
/**
|
||||
* @details Same as @p port_disable() in this port, there is no difference
|
||||
* between the two states.
|
||||
*/
|
||||
#define port_suspend() asm ("wrteei 0")
|
||||
|
||||
/**
|
||||
* @details Implemented as global interrupt enable.
|
||||
*/
|
||||
#define port_enable() asm ("wrteei 1")
|
||||
|
||||
/**
|
||||
* @details This port function is implemented as inlined code for performance
|
||||
* reasons.
|
||||
*/
|
||||
#if ENABLE_WFI_IDLE != 0
|
||||
#ifndef port_wait_for_interrupt
|
||||
#define port_wait_for_interrupt() { \
|
||||
asm ("wait"); \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define port_wait_for_interrupt()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void port_halt(void);
|
||||
void port_switch(Thread *otp, Thread *ntp);
|
||||
void _port_thread_start(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CHCORE_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file PPCE200Z/chtypes.h
|
||||
* @brief PPC E200Zx architecture port system types.
|
||||
* @addtogroup PPCE200Z_CORE
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _CHTYPES_H_
|
||||
#define _CHTYPES_H_
|
||||
|
||||
#define __need_NULL
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
|
||||
#if !defined(_STDINT_H) && !defined(__STDINT_H_)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Derived generic types.
|
||||
*/
|
||||
typedef volatile int8_t vint8_t; /**< Volatile signed 8 bits. */
|
||||
typedef volatile uint8_t vuint8_t; /**< Volatile unsigned 8 bits. */
|
||||
typedef volatile int16_t vint16_t; /**< Volatile signed 16 bits. */
|
||||
typedef volatile uint16_t vuint16_t; /**< Volatile unsigned 16 bits. */
|
||||
typedef volatile int32_t vint32_t; /**< Volatile signed 32 bits. */
|
||||
typedef volatile uint32_t vuint32_t; /**< Volatile unsigned 32 bits. */
|
||||
|
||||
/*
|
||||
* Kernel types.
|
||||
*/
|
||||
typedef int32_t bool_t; /**< Fast boolean type. */
|
||||
typedef uint8_t tmode_t; /**< Thread flags. */
|
||||
typedef uint8_t tstate_t; /**< Thread state. */
|
||||
typedef uint8_t trefs_t; /**< Thread references counter. */
|
||||
typedef uint32_t tprio_t; /**< Thread priority. */
|
||||
typedef int32_t msg_t; /**< Inter-thread message. */
|
||||
typedef int32_t eventid_t; /**< Event Id. */
|
||||
typedef uint32_t eventmask_t; /**< Events mask. */
|
||||
typedef uint32_t systime_t; /**< System time. */
|
||||
typedef int32_t cnt_t; /**< Resources counter. */
|
||||
|
||||
/** Inline function modifier. */
|
||||
#define INLINE inline
|
||||
|
||||
/** Packed structure modifier (within). */
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
|
||||
/** Packed structure modifier (before). */
|
||||
#define PACK_STRUCT_BEGIN
|
||||
|
||||
/** Packed structure modifier (after). */
|
||||
#define PACK_STRUCT_END
|
||||
|
||||
#endif /* _CHTYPES_H_ */
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file PPC/crt0.s
|
||||
* @brief Generic PowerPC startup file for ChibiOS/RT.
|
||||
*
|
||||
* @addtogroup PPC_CORE
|
||||
* @{
|
||||
*/
|
||||
/** @cond never */
|
||||
|
||||
.section .text
|
||||
.align 2
|
||||
.globl _boot_address
|
||||
_boot_address:
|
||||
/*
|
||||
* Stack setup.
|
||||
*/
|
||||
lis %r1, __ram_end__@h
|
||||
ori %r1, %r1, __ram_end__@l
|
||||
li %r0, 0
|
||||
stwu %r0, -8(%r1)
|
||||
/*
|
||||
* Early initialization.
|
||||
*/
|
||||
bl hwinit0
|
||||
/*
|
||||
* BSS clearing.
|
||||
*/
|
||||
lis %r4, __bss_start__@h
|
||||
ori %r4, %r4, __bss_start__@l
|
||||
lis %r5, __bss_end__@h
|
||||
ori %r5, %r5, __bss_end__@l
|
||||
li %r7, 0
|
||||
.bssloop:
|
||||
cmpl cr0, %r4, %r5
|
||||
bge cr0, .bssend
|
||||
stw %r7, 0(%r4)
|
||||
addi %r4, %r4, 4
|
||||
b .bssloop
|
||||
.bssend:
|
||||
/*
|
||||
* DATA initialization.
|
||||
*/
|
||||
lis %r4, __romdata_start__@h
|
||||
ori %r4, %r4, __romdata_start__@l
|
||||
lis %r5, __data_start__@h
|
||||
ori %r5, %r5, __data_start__@l
|
||||
lis %r6, __data_end__@h
|
||||
ori %r6, %r6, __data_end__@l
|
||||
.dataloop:
|
||||
cmpl cr0, %r5, %r6
|
||||
bge cr0, .dataend
|
||||
lwz %r7, 0(%r4)
|
||||
addi %r4, %r4, 4
|
||||
stw %r7, 0(%r5)
|
||||
addi %r5, %r5, 4
|
||||
b .dataloop
|
||||
.dataend:
|
||||
/*
|
||||
* Small sections registers initialization.
|
||||
*/
|
||||
lis %r2, __sdata2_start__@h
|
||||
ori %r2, %r2, __sdata2_start__@l
|
||||
lis %r13, __sdata_start__@h
|
||||
ori %r13, %r13, __sdata_start__@l
|
||||
/*
|
||||
* IVPR initialization.
|
||||
*/
|
||||
lis %r4, __ivpr_base__@h
|
||||
mtIVPR %r4
|
||||
/*
|
||||
* Late initialization.
|
||||
*/
|
||||
bl hwinit1
|
||||
li %r3, 0
|
||||
li %r4, 0
|
||||
bl main
|
||||
b main_exit
|
||||
|
||||
/*
|
||||
* Default main exit code, infinite loop.
|
||||
*/
|
||||
.weak main_exit
|
||||
.globl main_exit
|
||||
main_exit:
|
||||
forever:
|
||||
b forever
|
||||
|
||||
/*
|
||||
* Default initialization code, none.
|
||||
*/
|
||||
.weak hwinit0
|
||||
.globl hwinit0
|
||||
hwinit0:
|
||||
.weak hwinit1
|
||||
.globl hwinit1
|
||||
hwinit1:
|
||||
blr
|
||||
|
||||
/** @endcond */
|
||||
/** @} */
|
|
@ -0,0 +1,6 @@
|
|||
# List of the ChibiOS/RT PPC port files.
|
||||
PORTSRC = ${CHIBIOS}/os/ports/GCC/PPC/chcore.c
|
||||
|
||||
PORTASM = ${CHIBIOS}/os/ports/GCC/PPC/crt0.s
|
||||
|
||||
PORTINC = ${CHIBIOS}/os/ports/GCC/PPC
|
|
@ -0,0 +1,87 @@
|
|||
# PPC e200Z makefile scripts and rules.
|
||||
|
||||
# Automatic compiler options
|
||||
OPT = $(USE_OPT)
|
||||
CPPOPT = $(USE_CPPOPT)
|
||||
ifeq ($(USE_CURRP_CACHING),yes)
|
||||
OPT += -ffixed-r7 -DCH_CURRP_REGISTER_CACHE='"r7"'
|
||||
endif
|
||||
ifeq ($(USE_LINK_GC),yes)
|
||||
OPT += -ffunction-sections -fdata-sections
|
||||
endif
|
||||
|
||||
# Source files groups
|
||||
SRC = $(CSRC)$(CPPSRC)
|
||||
|
||||
# Object files groups
|
||||
COBJS = $(CSRC:.c=.o)
|
||||
CPPOBJS = $(CPPSRC:.cpp=.o)
|
||||
ASMOBJS = $(ASMSRC:.s=.o)
|
||||
OBJS = $(ASMOBJS) $(COBJS) $(CPPOBJS)
|
||||
|
||||
# Paths
|
||||
IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
|
||||
LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
||||
|
||||
# Macros
|
||||
DEFS = $(DDEFS) $(UDEFS)
|
||||
ADEFS = $(DADEFS) $(UADEFS)
|
||||
|
||||
# Libs
|
||||
LIBS = $(DLIBS) $(ULIBS)
|
||||
|
||||
MCFLAGS = -mcpu=$(MCU)
|
||||
ODFLAGS = -x --syms
|
||||
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
|
||||
CPFLAGS = $(MCFLAGS) $(OPT) $(CWARN) -Wa,-alms=$(<:.c=.lst) $(DEFS)
|
||||
ifeq ($(LINK_GC),yes)
|
||||
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
|
||||
else
|
||||
LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
|
||||
endif
|
||||
|
||||
# Generate dependency information
|
||||
CPFLAGS += -MD -MP -MF .dep/$(@F).d
|
||||
|
||||
#
|
||||
# Makefile rules
|
||||
#
|
||||
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).dmp
|
||||
|
||||
$(CPPOBJS) : %.o : %.cpp
|
||||
@echo
|
||||
$(CPPC) -c $(CPPFLAGS) -I . $(IINCDIR) $< -o $@
|
||||
|
||||
$(COBJS) : %.o : %.c
|
||||
@echo
|
||||
$(CC) -c $(CPFLAGS) -I . $(IINCDIR) $< -o $@
|
||||
|
||||
$(ASMOBJS) : %.o : %.s
|
||||
@echo
|
||||
$(AS) -c $(ASFLAGS) -I . $(IINCDIR) $< -o $@
|
||||
|
||||
%elf: $(OBJS)
|
||||
@echo
|
||||
$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
||||
|
||||
%hex: %elf
|
||||
$(HEX) $< $@
|
||||
|
||||
%bin: %elf
|
||||
$(BIN) $< $@
|
||||
|
||||
%dmp: %elf
|
||||
$(OD) $(ODFLAGS) $< > $@
|
||||
|
||||
clean:
|
||||
-rm -f $(OBJS)
|
||||
-rm -f $(CSRC:.c=.lst) $(CPPSRC:.cpp=.lst) $(ASMSRC:.s=.lst)
|
||||
-rm -f $(PROJECT).elf $(PROJECT).dmp $(PROJECT).map $(PROJECT).hex $(PROJECT).bin
|
||||
-rm -fR .dep
|
||||
|
||||
#
|
||||
# Include the dependency files, should be the last of the makefile
|
||||
#
|
||||
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||
|
||||
# *** EOF ***
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file memstreams.c
|
||||
* @brief Memory streams code.
|
||||
*
|
||||
* @addtogroup memory_streams
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ch.h"
|
||||
#include "memstreams.h"
|
||||
|
||||
/*
|
||||
* @brief Write virtual method implementation.
|
||||
*
|
||||
* @param[in] ip pointer to a @p MemoryStream object
|
||||
* @param[in] bp pointer to the data buffer
|
||||
* @param[in] n the maximum amount of data to be transferred
|
||||
* @return The number of bytes transferred. The return value can
|
||||
* be less than the specified number of bytes if the
|
||||
* stream reaches a physical end of file and cannot be
|
||||
* extended.
|
||||
*/
|
||||
static size_t writes(void *ip, const uint8_t *bp, size_t n) {
|
||||
MemoryStream *msp = ip;
|
||||
|
||||
if (msp->size - msp->eos < n)
|
||||
n = msp->size - msp->eos;
|
||||
memcpy(msp->buffer + msp->eos, bp, n);
|
||||
msp->eos += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Read virtual method implementation.
|
||||
*
|
||||
* @param[in] ip pointer to a @p MemoryStream object
|
||||
* @param[out] bp pointer to the data buffer
|
||||
* @param[in] n the maximum amount of data to be transferred
|
||||
* @return The number of bytes transferred. The return value can
|
||||
* be less than the specified number of bytes if the
|
||||
* stream reaches the end of the available data.
|
||||
*/
|
||||
static size_t reads(void *ip, uint8_t *bp, size_t n) {
|
||||
MemoryStream *msp = ip;
|
||||
|
||||
if (msp->eos - msp->offset < n)
|
||||
n = msp->eos - msp->offset;
|
||||
memcpy(bp, msp->buffer + msp->offset, n);
|
||||
msp->offset += n;
|
||||
return n;
|
||||
}
|
||||
|
||||
static const struct MemStreamVMT vmt = {writes, reads};
|
||||
|
||||
/**
|
||||
* @brief Memory stream object initialization.
|
||||
*
|
||||
* @param[out] msp pointer to the @p MemoryStream object to be initialized
|
||||
* @param[in] buffer pointer to the memory buffer for the memory stream
|
||||
* @param[in] size total size of the memory stream buffer
|
||||
* @param[in] eos initial End Of Stream offset. Normally you need to
|
||||
* put this to zero for RAM buffers or equal to @p size
|
||||
* for ROM streams.
|
||||
*/
|
||||
void msObjectInit(MemoryStream *msp, uint8_t *buffer, size_t size, size_t eos) {
|
||||
|
||||
msp->vmt = &vmt;
|
||||
msp->buffer = buffer;
|
||||
msp->size = size;
|
||||
msp->eos = eos;
|
||||
msp->offset = 0;
|
||||
}
|
||||
|
||||
/** @} */
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file memstreams.c
|
||||
* @brief Memory streams structures and macros.
|
||||
|
||||
* @addtogroup memory_streams
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _MEMSTREAMS_H_
|
||||
#define _MEMSTREAMS_H_
|
||||
|
||||
/**
|
||||
* @brief @p RamStream specific data.
|
||||
*/
|
||||
#define _memory_stream_data \
|
||||
_base_sequental_stream_data \
|
||||
/* Pointer to the stream buffer.*/ \
|
||||
uint8_t *buffer; \
|
||||
/* Size of the stream.*/ \
|
||||
size_t size; \
|
||||
/* Current end of stream.*/ \
|
||||
size_t eos; \
|
||||
/* Current read offset.*/ \
|
||||
size_t offset;
|
||||
|
||||
/**
|
||||
* @brief @p MemStream virtual methods table.
|
||||
*/
|
||||
struct MemStreamVMT {
|
||||
_base_sequental_stream_methods
|
||||
};
|
||||
|
||||
/**
|
||||
* @extends BaseSequentialStream
|
||||
*
|
||||
* @brief Memory stream object.
|
||||
*/
|
||||
typedef struct {
|
||||
/** @brief Virtual Methods Table.*/
|
||||
const struct MemStreamVMT *vmt;
|
||||
_memory_stream_data
|
||||
} MemoryStream;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void msObjectInit(MemoryStream *msp, uint8_t *buffer, size_t size, size_t eos);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MEMSTREAMS_H_ */
|
||||
|
||||
/** @} */
|
|
@ -62,7 +62,11 @@
|
|||
objects (bug 2952961).
|
||||
- FIX: Wrong prototype in template file chcore.c (bug 2951529)(backported
|
||||
in 1.4.1).
|
||||
- NEW: Added an experimental PowerPC port targeting the SPC563M64/MPC563x
|
||||
ST/Freescale automotive SOCs. The port passed the whole test suite but it
|
||||
will be developed further in next releases.
|
||||
- NEW: Added BOARD_NAME macro to the various board.h files.
|
||||
- NEW: Added a MemoryStream class under ./os/various.
|
||||
|
||||
*** 1.5.1 ***
|
||||
- FIX: Fixed insufficient stack space for the idle thread in the ARMCM3 port
|
||||
|
|
Loading…
Reference in New Issue