Updated the coverage tool.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1145 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2009-08-30 17:21:10 +00:00
parent 07be1f54be
commit d88897bf4d
7 changed files with 251 additions and 94 deletions

View File

@ -63,15 +63,14 @@ include ../../test/test.mk
# List C source files here # List C source files here
SRC = ${KERNSRC} \ SRC = ${KERNSRC} \
${TESTSRC} \ ${TESTSRC} \
chcore.c \ ../../os/io/serial.c \
simcom.c \ chcore.c serial_lld.c main.c
main.c
# List ASM source files here # List ASM source files here
ASRC = ASRC =
# List all user directories here # List all user directories here
UINCDIR = $(KERNINC) $(TESTINC) UINCDIR = $(KERNINC) $(TESTINC) ../../os/io
# List the user directory to look for the libraries here # List the user directory to look for the libraries here
ULIBDIR = ULIBDIR =

View File

@ -232,16 +232,6 @@
#define CH_USE_QUEUES TRUE #define CH_USE_QUEUES TRUE
#endif #endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#if !defined(CH_USE_SERIAL_FULLDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/** /**
* If specified then the memory heap allocator APIs are included in the kernel. * If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE. * @note The default is @p TRUE.

View File

@ -20,23 +20,17 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#undef CDECL
/** /**
* @addtogroup WIN32SIM_CORE * @addtogroup WIN32SIM_CORE
* @{ * @{
*/ */
#include <ch.h> #include <ch.h>
#include <serial.h>
static LARGE_INTEGER nextcnt; static LARGE_INTEGER nextcnt;
static LARGE_INTEGER slice; static LARGE_INTEGER slice;
void init_simcom1(void);
bool_t com1_conn_chkint(void);
bool_t com1_in_chkint(void);
bool_t com1_out_chkint(void);
/* /*
* Simulated HW initialization. * Simulated HW initialization.
*/ */
@ -53,7 +47,7 @@ void InitCore(void) {
QueryPerformanceCounter(&nextcnt); QueryPerformanceCounter(&nextcnt);
nextcnt.QuadPart += slice.QuadPart; nextcnt.QuadPart += slice.QuadPart;
init_simcom1(); sdInit();
fflush(stdout); fflush(stdout);
} }
@ -65,7 +59,7 @@ void ChkIntSources(void) {
LARGE_INTEGER n; LARGE_INTEGER n;
bool_t rflag = FALSE; bool_t rflag = FALSE;
if (com1_conn_chkint() || com1_in_chkint() || com1_out_chkint()) { if (sd_lld_interrupt_pending()) {
if (chSchRescRequiredI()) if (chSchRescRequiredI())
rflag = TRUE; rflag = TRUE;
} }

View File

@ -17,15 +17,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <windows.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <ch.h> #include <ch.h>
#include <serial.h>
#include <test.h> #include <test.h>
extern FullDuplexDriver COM1;
/* /*
* Simulator main. * Simulator main.
*/ */
@ -33,8 +31,10 @@ int main(int argc, char *argv[]) {
msg_t result; msg_t result;
chSysInit(); chSysInit();
result = TestThread(&COM1); sdStart(&SD1, NULL);
chThdSleepMilliseconds(1); /* Gives time to flush COM1 output queue */
result = TestThread(&SD1);
chThdSleepMilliseconds(1); /* Gives time to flush SD1 output queue */
fflush(stdout); fflush(stdout);
if (result) if (result)
exit(1); exit(1);

116
test/coverage/serial_lld.c Normal file
View File

@ -0,0 +1,116 @@
/*
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 Win32/serial_lld.c
* @brief Win32 low level simulated serial driver code
* @addtogroup WIN32_SERIAL
* @{
*/
#include <windows.h>
#include <stdio.h>
#include <ch.h>
#include <serial.h>
/** @brief Test serial driver identifier.*/
SerialDriver SD1;
/** @brief Driver default configuration.*/
static const SerialDriverConfig default_config = {
};
/*===========================================================================*/
/* Low Level Driver local functions. */
/*===========================================================================*/
static bool_t sd1_conn_chkint(void) {
return FALSE;
}
static bool_t sd1_in_chkint(void) {
return FALSE;
}
static bool_t sd1_out_chkint(void) {
msg_t n;
bool_t rflag = FALSE;
while (TRUE) {
n = sdRequestDataI(&SD1);
if (n < 0) {
fflush(stdout);
return rflag;
}
fputc(n, stdout);
rflag = TRUE;
}
}
/*===========================================================================*/
/* Low Level Driver interrupt handlers. */
/*===========================================================================*/
/*===========================================================================*/
/* Low Level Driver exported functions. */
/*===========================================================================*/
/**
* Low level serial driver initialization.
*/
void sd_lld_init(void) {
sdObjectInit(&SD1, NULL, NULL);
}
/**
* @brief Low level serial driver configuration and (re)start.
*
* @param[in] sdp pointer to a @p SerialDriver object
* @param[in] config the architecture-dependent serial driver configuration.
* If this parameter is set to @p NULL then a default
* configuration is used.
*/
void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config) {
if (config == NULL)
config = &default_config;
}
/**
* @brief Low level serial driver stop.
* @details De-initializes the USART, stops the associated clock, resets the
* interrupt vector.
*
* @param[in] sdp pointer to a @p SerialDriver object
*/
void sd_lld_stop(SerialDriver *sdp) {
}
bool_t sd_lld_interrupt_pending(void) {
return sd1_conn_chkint() || sd1_in_chkint() || sd1_out_chkint();
}
/** @} */

124
test/coverage/serial_lld.h Normal file
View File

@ -0,0 +1,124 @@
/*
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 Win32/serial_lld.h
* @brief Win32 low level simulated serial driver header
* @addtogroup WIN32_SERIAL
* @{
*/
#ifndef _SERIAL_LLD_H_
#define _SERIAL_LLD_H_
#include <windows.h>
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
/**
* @brief Serial buffers size.
* @details Configuration parameter, you can change the depth of the queue
* buffers depending on the requirements of your application.
*/
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
#define SERIAL_BUFFERS_SIZE 1024
#endif
/*===========================================================================*/
/* Unsupported event flags and custom events. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
/**
* Serial Driver condition flags type.
*/
typedef uint32_t sdflags_t;
/**
* @brief @p SerialDriver specific data.
*/
struct _serial_driver_data {
/**
* Input queue, incoming data can be read from this input queue by
* using the queues APIs.
*/
InputQueue iqueue;
/**
* Output queue, outgoing data can be written to this output queue by
* using the queues APIs.
*/
OutputQueue oqueue;
/**
* Status Change @p EventSource. This event is generated when one or more
* condition flags change.
*/
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];
};
/**
* @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 {
} SerialDriverConfig;
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
/** @cond never*/
extern SerialDriver SD1;
#ifdef __cplusplus
extern "C" {
#endif
void sd_lld_init(void);
void sd_lld_start(SerialDriver *sdp, const SerialDriverConfig *config);
void sd_lld_stop(SerialDriver *sdp);
bool_t sd_lld_interrupt_pending(void);
#ifdef __cplusplus
}
#endif
/** @endcond*/
#endif /* _SERIAL_LLD_H_ */
/** @} */

View File

@ -1,66 +0,0 @@
/*
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/>.
*/
/*
* Win32 COM port simulator (on stdout).
*/
#include <chconf.h>
#include <windows.h>
#include <stdio.h>
#undef CDECL
#include <ch.h>
FullDuplexDriver COM1;
static uint8_t com_ib[1024];
static uint8_t com_ob[1024];
void init_simcom1(void) {
chFDDInit(&COM1, com_ib, sizeof(com_ib), NULL, com_ob, sizeof(com_ob), NULL);
}
bool_t com1_conn_chkint(void) {
return FALSE;
}
bool_t com1_in_chkint(void) {
return FALSE;
}
bool_t com1_out_chkint(void) {
msg_t n;
bool_t rflag = FALSE;
while (TRUE) {
n = chFDDRequestDataI(&COM1);
if (n < 0) {
fflush(stdout);
return rflag;
}
fputc(n, stdout);
rflag = TRUE;
}
}