From 476270c2ab91169a8e731562b0e68b86602e0d77 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 4 Nov 2014 10:51:23 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7475 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal.h | 9 +- os/hal/ports/simulator/st_lld.c | 67 ++++++++++++++ os/hal/ports/simulator/st_lld.h | 141 ++++++++++++++++++++++++++++++ os/hal/ports/simulator/win32/hal_lld.c | 10 +-- os/hal/ports/simulator/win32/platform.mk | 3 +- os/hal/ports/simulator/win32/serial_lld.c | 4 +- os/hal/ports/simulator/win32/serial_lld.h | 4 +- os/hal/src/hal.c | 7 +- os/rt/ports/SIMIA32/chcore.c | 2 +- os/rt/ports/SIMIA32/chcore.h | 6 +- 10 files changed, 236 insertions(+), 17 deletions(-) create mode 100644 os/hal/ports/simulator/st_lld.c create mode 100644 os/hal/ports/simulator/st_lld.h (limited to 'os') diff --git a/os/hal/include/hal.h b/os/hal/include/hal.h index c29eee17d..5fda51fef 100644 --- a/os/hal/include/hal.h +++ b/os/hal/include/hal.h @@ -61,10 +61,17 @@ #include "serial.h" #include "sdc.h" #include "spi.h" -#include "st.h" #include "uart.h" #include "usb.h" +/* + * The ST driver is a special case, it is only included if the OSAL is + * configured to require it. + */ +#if OSAL_ST_MODE != OSAL_ST_MODE_NONE +#include "st.h" +#endif + /* Complex drivers.*/ #include "mmc_spi.h" #include "serial_usb.h" diff --git a/os/hal/ports/simulator/st_lld.c b/os/hal/ports/simulator/st_lld.c new file mode 100644 index 000000000..d6768ddf9 --- /dev/null +++ b/os/hal/ports/simulator/st_lld.c @@ -0,0 +1,67 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2014 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file st_lld.c + * @brief PLATFORM ST subsystem low level driver source. + * + * @addtogroup ST + * @{ + */ + +#include "hal.h" + +#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/** + * @brief Low level ST driver initialization. + * + * @notapi + */ +void st_lld_init(void) { +} + +#endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */ + +/** @} */ diff --git a/os/hal/ports/simulator/st_lld.h b/os/hal/ports/simulator/st_lld.h new file mode 100644 index 000000000..b5de30a6d --- /dev/null +++ b/os/hal/ports/simulator/st_lld.h @@ -0,0 +1,141 @@ +/* + ChibiOS/RT - Copyright (C) 2006-2014 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file st_lld.h + * @brief PLATFORM ST subsystem low level driver header. + * @details This header is designed to be include-able without having to + * include other files from the HAL. + * + * @addtogroup ST + * @{ + */ + +#ifndef _ST_LLD_H_ +#define _ST_LLD_H_ + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void st_lld_init(void); +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Driver inline functions. */ +/*===========================================================================*/ + +/** + * @brief Returns the time counter value. + * + * @return The counter value. + * + * @notapi + */ +static inline systime_t st_lld_get_counter(void) { + + return (systime_t)0; +} + +/** + * @brief Starts the alarm. + * @note Makes sure that no spurious alarms are triggered after + * this call. + * + * @param[in] time the time to be set for the first alarm + * + * @notapi + */ +static inline void st_lld_start_alarm(systime_t time) { + + (void)time; +} + +/** + * @brief Stops the alarm interrupt. + * + * @notapi + */ +static inline void st_lld_stop_alarm(void) { + +} + +/** + * @brief Sets the alarm time. + * + * @param[in] time the time to be set for the next alarm + * + * @notapi + */ +static inline void st_lld_set_alarm(systime_t time) { + + (void)time; +} + +/** + * @brief Returns the current alarm time. + * + * @return The currently set alarm time. + * + * @notapi + */ +static inline systime_t st_lld_get_alarm(void) { + + return (systime_t)0; +} + +/** + * @brief Determines if the alarm is active. + * + * @return The alarm status. + * @retval false if the alarm is not active. + * @retval true is the alarm is active + * + * @notapi + */ +static inline bool st_lld_is_alarm_active(void) { + + return false; +} + +#endif /* _ST_LLD_H_ */ + +/** @} */ diff --git a/os/hal/ports/simulator/win32/hal_lld.c b/os/hal/ports/simulator/win32/hal_lld.c index a42815c0c..555e749a0 100644 --- a/os/hal/ports/simulator/win32/hal_lld.c +++ b/os/hal/ports/simulator/win32/hal_lld.c @@ -64,7 +64,7 @@ void hal_lld_init(void) { printf("QueryPerformanceFrequency() error"); exit(1); } - slice.QuadPart /= CH_FREQUENCY; + slice.QuadPart /= CH_CFG_ST_FREQUENCY; QueryPerformanceCounter(&nextcnt); nextcnt.QuadPart += slice.QuadPart; @@ -79,10 +79,10 @@ void _sim_check_for_interrupts(void) { #if HAL_USE_SERIAL if (sd_lld_interrupt_pending()) { - dbg_check_lock(); + _dbg_check_lock(); if (chSchIsPreemptionRequired()) chSchDoReschedule(); - dbg_check_unlock(); + _dbg_check_unlock(); return; } #endif @@ -100,10 +100,10 @@ void _sim_check_for_interrupts(void) { CH_IRQ_EPILOGUE(); - dbg_check_lock(); + _dbg_check_lock(); if (chSchIsPreemptionRequired()) chSchDoReschedule(); - dbg_check_unlock(); + _dbg_check_unlock(); } } diff --git a/os/hal/ports/simulator/win32/platform.mk b/os/hal/ports/simulator/win32/platform.mk index 8136324e7..842309c62 100644 --- a/os/hal/ports/simulator/win32/platform.mk +++ b/os/hal/ports/simulator/win32/platform.mk @@ -1,7 +1,8 @@ # List of all the Win32 platform files. PLATFORMSRC = ${CHIBIOS}/os/hal/ports/simulator/win32/hal_lld.c \ ${CHIBIOS}/os/hal/ports/simulator/win32/serial_lld.c \ - ${CHIBIOS}/os/hal/ports/simulator/pal_lld.c + ${CHIBIOS}/os/hal/ports/simulator/pal_lld.c \ + ${CHIBIOS}/os/hal/ports/simulator/st_lld.c # Required include directories PLATFORMINC = ${CHIBIOS}/os/hal/ports/simulator/win32 \ diff --git a/os/hal/ports/simulator/win32/serial_lld.c b/os/hal/ports/simulator/win32/serial_lld.c index 7cf1e5b66..e33499f1f 100644 --- a/os/hal/ports/simulator/win32/serial_lld.c +++ b/os/hal/ports/simulator/win32/serial_lld.c @@ -133,7 +133,7 @@ static bool inint(SerialDriver *sdp) { /* * Input. */ - int n = recv(sdp->com_data, data, sizeof(data), 0); + int n = recv(sdp->com_data, (char *)data, sizeof(data), 0); switch (n) { case 0: closesocket(sdp->com_data); @@ -174,7 +174,7 @@ static bool outint(SerialDriver *sdp) { if (n < 0) return FALSE; data[0] = (uint8_t)n; - n = send(sdp->com_data, data, sizeof(data), 0); + n = send(sdp->com_data, (char *)data, sizeof(data), 0); switch (n) { case 0: closesocket(sdp->com_data); diff --git a/os/hal/ports/simulator/win32/serial_lld.h b/os/hal/ports/simulator/win32/serial_lld.h index 22fb36b8f..ba49bd671 100644 --- a/os/hal/ports/simulator/win32/serial_lld.h +++ b/os/hal/ports/simulator/win32/serial_lld.h @@ -99,9 +99,9 @@ typedef struct { /* Driver state.*/ \ sdstate_t state; \ /* Input queue.*/ \ - InputQueue iqueue; \ + input_queue_t iqueue; \ /* Output queue.*/ \ - OutputQueue oqueue; \ + output_queue_t oqueue; \ /* Input circular buffer.*/ \ uint8_t ib[SERIAL_BUFFERS_SIZE]; \ /* Output circular buffer.*/ \ diff --git a/os/hal/src/hal.c b/os/hal/src/hal.c index d9985993e..b49f7383e 100644 --- a/os/hal/src/hal.c +++ b/os/hal/src/hal.c @@ -122,8 +122,11 @@ void halInit(void) { /* Board specific initialization.*/ boardInit(); -#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__) - /* System tick service if the underlying OS requires it.*/ +/* + * The ST driver is a special case, it is only initialized if the OSAL is + * configured to require it. + */ +#if OSAL_ST_MODE != OSAL_ST_MODE_NONE stInit(); #endif } diff --git a/os/rt/ports/SIMIA32/chcore.c b/os/rt/ports/SIMIA32/chcore.c index b4357dfc7..244e4c30f 100644 --- a/os/rt/ports/SIMIA32/chcore.c +++ b/os/rt/ports/SIMIA32/chcore.c @@ -58,7 +58,7 @@ * @param ntp the thread to be switched in */ __attribute__((used)) -static void __dummy(Thread *ntp, Thread *otp) { +static void __dummy(thread_t *ntp, thread_t *otp) { (void)ntp; (void)otp; asm volatile ( diff --git a/os/rt/ports/SIMIA32/chcore.h b/os/rt/ports/SIMIA32/chcore.h index 9c8cd2587..6174f93eb 100644 --- a/os/rt/ports/SIMIA32/chcore.h +++ b/os/rt/ports/SIMIA32/chcore.h @@ -148,7 +148,7 @@ struct port_intctx { * at context switch time. */ struct context { - struct intctx volatile *esp; + struct port_intctx *esp; }; /*===========================================================================*/ @@ -177,11 +177,11 @@ struct context { APUSH(esp, pf); \ APUSH(esp, 0); \ esp -= sizeof(struct port_intctx); \ - ((struct port_intctx *)esp)->eip = _port_thread_start; \ + ((struct port_intctx *)esp)->eip = (void *)_port_thread_start; \ ((struct port_intctx *)esp)->ebx = 0; \ ((struct port_intctx *)esp)->edi = 0; \ ((struct port_intctx *)esp)->esi = 0; \ - ((struct port_intctx *)esp)->ebp = savebp; \ + ((struct port_intctx *)esp)->ebp = (void *)savebp; \ (tp)->p_ctx.esp = (struct port_intctx *)esp; \ } -- cgit v1.2.3