diff options
| author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-03-04 10:33:38 +0000 | 
|---|---|---|
| committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-03-04 10:33:38 +0000 | 
| commit | 99ac65be2ac3d59a4de3b5adaa4dd9adeb80c1e2 (patch) | |
| tree | f5b7095946f7b4553698e91adfe07f2bcaa1e110 /demos | |
| parent | ec0a917ae1bef32f1848161e759ef98542327523 (diff) | |
| download | ChibiOS-99ac65be2ac3d59a4de3b5adaa4dd9adeb80c1e2.tar.gz ChibiOS-99ac65be2ac3d59a4de3b5adaa4dd9adeb80c1e2.tar.bz2 ChibiOS-99ac65be2ac3d59a4de3b5adaa4dd9adeb80c1e2.zip  | |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@213 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos')
| -rw-r--r-- | demos/Win32-MSVS/ch.sln | 21 | ||||
| -rw-r--r-- | demos/Win32-MSVS/ch.vcproj | 267 | ||||
| -rw-r--r-- | demos/Win32-MSVS/chconf.h | 174 | ||||
| -rw-r--r-- | demos/Win32-MSVS/chcore.c | 115 | ||||
| -rw-r--r-- | demos/Win32-MSVS/chcore.h | 82 | ||||
| -rw-r--r-- | demos/Win32-MSVS/chtypes.h | 47 | ||||
| -rw-r--r-- | demos/Win32-MSVS/demo.c | 292 | ||||
| -rw-r--r-- | demos/Win32-MSVS/readme.txt | 22 | ||||
| -rw-r--r-- | demos/Win32-MinGW/chcore.h | 4 | ||||
| -rw-r--r-- | demos/Win32-MinGW/chtypes.h | 36 | ||||
| -rw-r--r-- | demos/Win32-MinGW/demo.c | 16 | 
11 files changed, 25 insertions, 1051 deletions
diff --git a/demos/Win32-MSVS/ch.sln b/demos/Win32-MSVS/ch.sln deleted file mode 100644 index cb9406206..000000000 --- a/demos/Win32-MSVS/ch.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00
 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ch", "ch.vcproj", "{0A528619-7F3F-4459-AAC5-DE8BA570D51D}"
 -	ProjectSection(ProjectDependencies) = postProject
 -	EndProjectSection
 -EndProject
 -Global
 -	GlobalSection(SolutionConfiguration) = preSolution
 -		Debug = Debug
 -		Release = Release
 -	EndGlobalSection
 -	GlobalSection(ProjectConfiguration) = postSolution
 -		{0A528619-7F3F-4459-AAC5-DE8BA570D51D}.Debug.ActiveCfg = Debug|Win32
 -		{0A528619-7F3F-4459-AAC5-DE8BA570D51D}.Debug.Build.0 = Debug|Win32
 -		{0A528619-7F3F-4459-AAC5-DE8BA570D51D}.Release.ActiveCfg = Release|Win32
 -		{0A528619-7F3F-4459-AAC5-DE8BA570D51D}.Release.Build.0 = Release|Win32
 -	EndGlobalSection
 -	GlobalSection(ExtensibilityGlobals) = postSolution
 -	EndGlobalSection
 -	GlobalSection(ExtensibilityAddIns) = postSolution
 -	EndGlobalSection
 -EndGlobal
 diff --git a/demos/Win32-MSVS/ch.vcproj b/demos/Win32-MSVS/ch.vcproj deleted file mode 100644 index 0b27e2ffb..000000000 --- a/demos/Win32-MSVS/ch.vcproj +++ /dev/null @@ -1,267 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
 -<VisualStudioProject
 -	ProjectType="Visual C++"
 -	Version="7.10"
 -	Name="ch"
 -	ProjectGUID="{0A528619-7F3F-4459-AAC5-DE8BA570D51D}"
 -	Keyword="Win32Proj">
 -	<Platforms>
 -		<Platform
 -			Name="Win32"/>
 -	</Platforms>
 -	<Configurations>
 -		<Configuration
 -			Name="Debug|Win32"
 -			OutputDirectory="Debug"
 -			IntermediateDirectory="Debug"
 -			ConfigurationType="1"
 -			CharacterSet="2">
 -			<Tool
 -				Name="VCCLCompilerTool"
 -				Optimization="0"
 -				AdditionalIncludeDirectories="..\..\src\include;."
 -				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
 -				MinimalRebuild="TRUE"
 -				ExceptionHandling="FALSE"
 -				RuntimeLibrary="5"
 -				UsePrecompiledHeader="0"
 -				AssemblerOutput="3"
 -				WarningLevel="3"
 -				Detect64BitPortabilityProblems="TRUE"
 -				DebugInformationFormat="4"
 -				CompileAs="1"/>
 -			<Tool
 -				Name="VCCustomBuildTool"/>
 -			<Tool
 -				Name="VCLinkerTool"
 -				AdditionalDependencies="WS2_32.lib"
 -				OutputFile="$(OutDir)/ch.exe"
 -				LinkIncremental="2"
 -				GenerateDebugInformation="TRUE"
 -				ProgramDatabaseFile="$(OutDir)/ch.pdb"
 -				GenerateMapFile="TRUE"
 -				MapFileName="Debug\ch.map"
 -				SubSystem="1"
 -				TargetMachine="1"/>
 -			<Tool
 -				Name="VCMIDLTool"/>
 -			<Tool
 -				Name="VCPostBuildEventTool"/>
 -			<Tool
 -				Name="VCPreBuildEventTool"/>
 -			<Tool
 -				Name="VCPreLinkEventTool"/>
 -			<Tool
 -				Name="VCResourceCompilerTool"/>
 -			<Tool
 -				Name="VCWebServiceProxyGeneratorTool"/>
 -			<Tool
 -				Name="VCXMLDataGeneratorTool"/>
 -			<Tool
 -				Name="VCWebDeploymentTool"/>
 -			<Tool
 -				Name="VCManagedWrapperGeneratorTool"/>
 -			<Tool
 -				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 -		</Configuration>
 -		<Configuration
 -			Name="Release|Win32"
 -			OutputDirectory="Release"
 -			IntermediateDirectory="Release"
 -			ConfigurationType="1"
 -			CharacterSet="2">
 -			<Tool
 -				Name="VCCLCompilerTool"
 -				Optimization="3"
 -				GlobalOptimizations="TRUE"
 -				FavorSizeOrSpeed="2"
 -				OmitFramePointers="TRUE"
 -				AdditionalIncludeDirectories="..\..\src\include;."
 -				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
 -				StringPooling="TRUE"
 -				ExceptionHandling="FALSE"
 -				RuntimeLibrary="4"
 -				BufferSecurityCheck="FALSE"
 -				UsePrecompiledHeader="0"
 -				AssemblerOutput="3"
 -				WarningLevel="3"
 -				Detect64BitPortabilityProblems="TRUE"
 -				DebugInformationFormat="3"
 -				CompileAs="1"/>
 -			<Tool
 -				Name="VCCustomBuildTool"/>
 -			<Tool
 -				Name="VCLinkerTool"
 -				AdditionalDependencies="WS2_32.lib"
 -				OutputFile="$(OutDir)/ch.exe"
 -				LinkIncremental="1"
 -				GenerateDebugInformation="TRUE"
 -				ProgramDatabaseFile="$(OutDir)/ch.pdb"
 -				GenerateMapFile="TRUE"
 -				MapFileName="Release\ch.map"
 -				SubSystem="1"
 -				OptimizeReferences="2"
 -				EnableCOMDATFolding="2"
 -				TargetMachine="1"/>
 -			<Tool
 -				Name="VCMIDLTool"/>
 -			<Tool
 -				Name="VCPostBuildEventTool"/>
 -			<Tool
 -				Name="VCPreBuildEventTool"/>
 -			<Tool
 -				Name="VCPreLinkEventTool"/>
 -			<Tool
 -				Name="VCResourceCompilerTool"/>
 -			<Tool
 -				Name="VCWebServiceProxyGeneratorTool"/>
 -			<Tool
 -				Name="VCXMLDataGeneratorTool"/>
 -			<Tool
 -				Name="VCWebDeploymentTool"/>
 -			<Tool
 -				Name="VCManagedWrapperGeneratorTool"/>
 -			<Tool
 -				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 -		</Configuration>
 -	</Configurations>
 -	<References>
 -	</References>
 -	<Files>
 -		<Filter
 -			Name="Source Files"
 -			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
 -			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
 -			<File
 -				RelativePath=".\chcore.c">
 -			</File>
 -			<File
 -				RelativePath=".\demo.c">
 -			</File>
 -			<Filter
 -				Name="src"
 -				Filter="">
 -				<File
 -					RelativePath="..\..\src\chdebug.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chdelta.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chevents.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chinit.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chlists.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chmsg.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chmtx.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chqueues.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chschd.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chsem.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chserial.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chsleep.c">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\chthreads.c">
 -				</File>
 -			</Filter>
 -			<Filter
 -				Name="win32"
 -				Filter="">
 -				<File
 -					RelativePath="..\..\ports\Win32\simcom.c">
 -				</File>
 -			</Filter>
 -		</Filter>
 -		<Filter
 -			Name="Header Files"
 -			Filter="h;hpp;hxx;hm;inl;inc;xsd"
 -			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
 -			<File
 -				RelativePath=".\chconf.h">
 -			</File>
 -			<File
 -				RelativePath=".\chcore.h">
 -			</File>
 -			<File
 -				RelativePath=".\chtypes.h">
 -			</File>
 -			<Filter
 -				Name="include"
 -				Filter="">
 -				<File
 -					RelativePath="..\..\src\include\ch.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\debug.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\delta.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\events.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\inline.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\lists.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\messages.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\mutexes.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\queues.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\scheduler.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\semaphores.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\serial.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\sleep.h">
 -				</File>
 -				<File
 -					RelativePath="..\..\src\include\threads.h">
 -				</File>
 -			</Filter>
 -		</Filter>
 -		<File
 -			RelativePath="..\..\docs\ch.txt">
 -		</File>
 -		<File
 -			RelativePath="..\..\license.txt">
 -		</File>
 -		<File
 -			RelativePath="..\..\readme.txt">
 -		</File>
 -		<File
 -			RelativePath="..\..\ToDo.txt">
 -		</File>
 -	</Files>
 -	<Globals>
 -	</Globals>
 -</VisualStudioProject>
 diff --git a/demos/Win32-MSVS/chconf.h b/demos/Win32-MSVS/chconf.h deleted file mode 100644 index 075f829d3..000000000 --- a/demos/Win32-MSVS/chconf.h +++ /dev/null @@ -1,174 +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/>.
 -*/
 -
 -/*
 - * Configuration file for Visual Studio 7 demo project.
 - */
 -
 -/**
 - * @addtogroup Config
 - * @{
 - */
 -
 -#ifndef _CHCONF_H_
 -#define _CHCONF_H_
 -
 -/*
 - * NOTE: this is just documentation for doxigen, the real configuration file
 - * is the one into the project directories.
 - */
 -
 -/** Configuration option: if specified then time efficient rather than space
 - *  efficient code is used when two possible implementations exist, note
 - *  that this is not related to the compiler optimization options.*/
 -#define CH_OPTIMIZE_SPEED
 -
 -/** Configuration option: if specified then the Virtual Timers subsystem is
 - *  included in the kernel.*/
 -#define CH_USE_VIRTUAL_TIMERS
 -
 -/** Configuration option: if specified then the System Timer subsystem is
 - *  included in the kernel.*/
 -#define CH_USE_SYSTEMTIME
 -
 -/** Configuration option: if specified then the \p chThdSleep() function is
 - *  included in the kernel.
 - * @note requires \p CH_USE_VIRTUAL_TIMERS.*/
 -#define CH_USE_SLEEP
 -
 -/** Configuration option: if specified then the \p chThdResume()
 - *  function is included in the kernel.*/
 -#define CH_USE_RESUME
 -
 -/** Configuration option: if specified then the \p chThdSuspend()
 - *  function is included in the kernel.*/
 -#define CH_USE_SUSPEND
 -
 -/** Configuration option: if specified then the \p chThdTerminate()
 - *  and \p chThdShouldTerminate() functions are included in the kernel.*/
 -#define CH_USE_TERMINATE
 -
 -/** Configuration option: if specified then the \p chThdWait() function
 - *  is included in the kernel.*/
 -#define CH_USE_WAITEXIT
 -
 -/** Configuration option: if specified then the Semaphores APIs are included
 - *  in the kernel.*/
 -#define CH_USE_SEMAPHORES
 -
 -/** Configuration option: if specified then the Semaphores atomic Signal+Wait
 - *  APIs are included in the kernel.*/
 -#define CH_USE_SEMSW
 -
 -/** Configuration option: if specified then the Semaphores with timeout APIs
 - *  are included in the kernel.
 - * @note requires \p CH_USE_SEMAPHORES.
 - * @note requires \p CH_USE_VIRTUAL_TIMERS.*/
 -#define CH_USE_SEMAPHORES_TIMEOUT
 -
 -/** Configuration option: if specified then the Mutexes APIs are included in
 - * the kernel.*/
 -#define CH_USE_MUTEXES
 -
 -/** Configuration option: if specified then the Events APIs are included in
 - *  the kernel.*/
 -#define CH_USE_EVENTS
 -
 -/** Configuration option: if specified then the \p chEvtWaitTimeout()
 - *  function is included in the kernel.
 - * @note requires \p CH_USE_EVENTS.
 - * @note requires \p CH_USE_VIRTUAL_TIMERS.*/
 -#define CH_USE_EVENTS_TIMEOUT
 -
 -/** Configuration option: if specified then the Synchronous Messages APIs are
 - *  included in the kernel.*/
 -#define CH_USE_MESSAGES
 -
 -/** Configuration option: if specified then the \p chMsgSendWithEvent()
 - *  function is included in the kernel.
 - * @note requires \p CH_USE_MESSAGES.
 - * @note requires \p CH_USE_VIRTUAL_TIMERS.*/
 -#define CH_USE_MESSAGES_EVENT
 -
 -/** Configuration option: If enabled then the threads have an option to serve
 - *  messages by priority instead of FIFO order.
 - * @note requires \p CH_USE_MESSAGES.*/
 -//#define CH_USE_MESSAGES_PRIORITY
 -
 -/** Configuration option: if specified then the
 - *  \p chThdGetExitEventSource() function is included in the kernel.
 - * @note requires \p CH_USE_MESSAGES.
 - * @note requires \p CH_USE_EVENTS.*/
 -#define CH_USE_EXIT_EVENT
 -
 -/** Configuration option: if specified then the I/O queues APIs are included
 - *  in the kernel.*/
 -#define CH_USE_QUEUES
 -
 -/** Configuration option: if specified then the halfduplex queue APIs are
 - *  included in the kernel.*/
 -#define CH_USE_QUEUES_HALFDUPLEX
 -
 -/** Configuration option: if specified then the I/O queues with timeout
 - *  APIs are included in the kernel.
 - * @note requires \p CH_USE_SEMAPHORES_TIMEOUT.*/
 -#define CH_USE_QUEUES_TIMEOUT
 -
 -/** Configuration option: if specified then the full duplex serial driver APIs
 - *  are included in the kernel.*/
 -#define CH_USE_SERIAL_FULLDUPLEX
 -
 -/** Configuration option: if specified then the half duplex serial driver APIs
 - *  are included in the kernel.*/
 -#define CH_USE_SERIAL_HALFDUPLEX
 -
 -/** Configuration option: Frequency of the system timer that drives the system
 - *  ticks. This also defines the system time unit.*/
 -#define CH_FREQUENCY 1000
 -
 -/** Configuration option: This constant is the number of ticks allowed for the
 - *  threads before preemption occurs.*/
 -#define CH_TIME_QUANTUM 20
 -
 -/** Configuration option: Defines a CPU register to be used as storage for the
 - *  global \p currp variable. Caching this variable in a register can greatly
 - *  improve both space and time efficiency of the generated code. Another side
 - *  effect is that one less register has to be saved during the context switch
 - *  resulting in lower RAM usage and faster code.
 - *  @note This option is only useable 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\>.
 - */
 -//#define CH_CURRP_REGISTER_CACHE "reg"
 -
 -/** Configuration option: Includes basic debug support to the kernel.
 - *  @note the debug support is port-dependent, it may be not present on some
 - *       targets. In that case stub functions will be included.
 - */
 -//#define CH_USE_DEBUG
 -
 -/** Debug option: Includes the threads context switch tracing feature.
 - */
 -//#define CH_USE_TRACE
 -
 -#endif  /* _CHCONF_H_ */
 -
 -/** @} */
 diff --git a/demos/Win32-MSVS/chcore.c b/demos/Win32-MSVS/chcore.c deleted file mode 100644 index facdea31c..000000000 --- a/demos/Win32-MSVS/chcore.c +++ /dev/null @@ -1,115 +0,0 @@ -#include <windows.h>
 -#include <stdio.h>
 -
 -#undef CDECL
 -
 -#include <ch.h>
 -
 -static LARGE_INTEGER nextcnt;
 -static LARGE_INTEGER slice;
 -
 -void InitSimCom1(void);
 -void InitSimCom2(void);
 -BOOL Com1ConnInterruptSimCom(void);
 -BOOL Com2ConnInterruptSimCom(void);
 -BOOL Com1InInterruptSimCom(void);
 -BOOL Com2InInterruptSimCom(void);
 -BOOL Com1OutInterruptSimCom(void);
 -BOOL Com2OutInterruptSimCom(void);
 -
 -/*
 - * Simulated HW initialization.
 - */
 -void InitCore(void) {
 -  WSADATA wsaData;
 -
 -  // Initialization.
 -  if (WSAStartup(2, &wsaData) != 0) {
 -    printf("Unable to locate a winsock DLL\n");
 -    exit(1);
 -  }
 -
 -  printf("Win32 ChibiOS/RT simulator\n\n");
 -  printf("Thread structure %d bytes\n", sizeof(Thread));
 -  if (!QueryPerformanceFrequency(&slice)) {
 -    printf("QueryPerformanceFrequency() error");
 -    exit(1);
 -  }
 -  printf("Core Frequency   %u Hz\n", slice.LowPart);
 -  slice.QuadPart /= CH_FREQUENCY;
 -  QueryPerformanceCounter(&nextcnt);
 -  nextcnt.QuadPart += slice.QuadPart;
 -
 -  InitSimCom1();
 -  InitSimCom2();
 -}
 -
 -/*
 - * Interrupt simulation.
 - */
 -void ChkIntSources(void) {
 -  LARGE_INTEGER n;
 -
 -  if (Com1InInterruptSimCom()   || Com2InInterruptSimCom()  ||
 -      Com1OutInterruptSimCom()  || Com2OutInterruptSimCom() ||
 -      Com1ConnInterruptSimCom() || Com2ConnInterruptSimCom()) {
 -    if (chSchRescRequiredI())
 -      chSchDoRescheduleI();
 -    return;
 -  }
 -
 -  // Interrupt Timer simulation (10ms interval).
 -  QueryPerformanceCounter(&n);
 -  if (n.QuadPart > nextcnt.QuadPart) {
 -    nextcnt.QuadPart += slice.QuadPart;
 -    chSysTimerHandlerI();
 -    if (chSchRescRequiredI())
 -      chSchDoRescheduleI();
 -  }
 -}
 -
 -t_msg _IdleThread(void *p) {
 -
 -  chThdSetPriority(IDLEPRIO);
 -
 -  while (TRUE) {
 -
 -    ChkIntSources();
 -    Sleep(0);
 -  }
 -}
 -
 -__declspec(naked) void __fastcall chSysHalt(void) {
 -
 -  exit(2);
 -}
 -
 -__declspec(naked) void __fastcall chSysSwitchI(Thread *otp, Thread *ntp) {
 -
 -  __asm {
 -    // Switch out code
 -    push    ebp
 -    push    esi
 -    push    edi
 -    push    ebx
 -    mov     dword ptr 16[ecx],esp
 -    // Switch in code
 -    mov     esp,16[edx]
 -    pop     ebx
 -    pop     edi
 -    pop     esi
 -    pop     ebp
 -    ret
 -  }
 -}
 -
 -__declspec(naked) void __fastcall threadexit(void) {
 -
 -  __asm {
 -//    add     esp,4                 ; The thread parameter
 -    push    eax                   ; The exit code returned by the thread
 -    call    chThdExit
 -    add     esp,4
 -    call    chSysHalt             ; Should *never* happen
 -  }
 -}
 diff --git a/demos/Win32-MSVS/chcore.h b/demos/Win32-MSVS/chcore.h deleted file mode 100644 index 18e96dc13..000000000 --- a/demos/Win32-MSVS/chcore.h +++ /dev/null @@ -1,82 +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/>.
 -*/
 -
 -/*
 - * Core file for Visual Studio 7 demo project.
 - */
 -
 -#ifndef _CHCORE_H_
 -#define _CHCORE_H_
 -
 -typedef void *regx86;
 -
 -/*
 - * Stack saved context.
 - */
 -struct intctx {
 -  regx86  ebx;
 -  regx86  edi;
 -  regx86  esi;
 -  regx86  ebp;
 -  regx86  eip;
 -};
 -
 -typedef struct {
 -  struct intctx *esp;
 -} Context;
 -
 -#define APUSH(p, a) (p) -= sizeof(void *), *(void **)(p) = (void*)(a)
 -
 -#define SETUP_CONTEXT(workspace, wsize, pf, arg)                        \
 -{                                                                       \
 -  BYTE8 *esp = (BYTE8 *)workspace + wsize;                              \
 -  APUSH(esp, arg);                                                      \
 -  APUSH(esp, threadexit);                                               \
 -  esp -= sizeof(struct intctx);                                         \
 -  ((struct intctx *)esp)->eip = pf;                                     \
 -  ((struct intctx *)esp)->ebx = 0;                                      \
 -  ((struct intctx *)esp)->edi = 0;                                      \
 -  ((struct intctx *)esp)->esi = 0;                                      \
 -  ((struct intctx *)esp)->ebp = 0;                                      \
 -  tp->p_ctx.esp = (struct intctx *)esp;                                 \
 -}
 -
 -#define chSysLock()
 -#define chSysUnlock()
 -#define chSysPuts(msg) {}
 -#define chSysIRQEnterI()
 -#define chSysIRQExitI()
 -
 -#define INT_REQUIRED_STACK 0
 -#define StackAlign(n) ((((n) - 1) | 3) + 1)
 -#define UserStackSize(n) StackAlign(sizeof(Thread) +                    \
 -                                    sizeof(void *) * 2 +                \
 -                                    sizeof(struct intctx) +             \
 -                                    (n) +                               \
 -                                    INT_REQUIRED_STACK)
 -#define WorkingArea(s, n) ULONG32 s[UserStackSize(n) >> 2];
 -
 -#define IDLE_THREAD_STACK_SIZE 16384
 -t_msg _IdleThread(void *p);
 -
 -void __fastcall chSysHalt(void);
 -void __fastcall chSysSwitchI(Thread *otp, Thread *ntp);
 -void __fastcall threadexit(void);
 -
 -#endif /* _CHCORE_H_ */
 diff --git a/demos/Win32-MSVS/chtypes.h b/demos/Win32-MSVS/chtypes.h deleted file mode 100644 index 5ab9a06e1..000000000 --- a/demos/Win32-MSVS/chtypes.h +++ /dev/null @@ -1,47 +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/>.
 -*/
 -
 -#ifndef _CHTYPES_H_
 -#define _CHTYPES_H_
 -
 -/*
 - * Generic types often dependant on the compiler.
 - */
 -#define BOOL        char
 -#define BYTE8       unsigned char
 -#define SBYTE8      char
 -#define WORD16      short
 -#define UWORD16     unsigned short
 -#define LONG32      int
 -#define ULONG32     unsigned int
 -
 -typedef BYTE8       t_tmode;
 -typedef BYTE8       t_tstate;
 -typedef UWORD16     t_tid;
 -typedef ULONG32     t_prio;
 -typedef LONG32      t_msg;
 -typedef LONG32      t_eventid;
 -typedef ULONG32     t_eventmask;
 -typedef ULONG32     t_time;
 -typedef LONG32      t_cnt;
 -typedef ULONG32     t_size;
 -
 -#define INLINE      __inline
 -
 -#endif /* _CHTYPES_H_ */
 diff --git a/demos/Win32-MSVS/demo.c b/demos/Win32-MSVS/demo.c deleted file mode 100644 index 5a3bf167c..000000000 --- a/demos/Win32-MSVS/demo.c +++ /dev/null @@ -1,292 +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/>.
 -*/
 -
 -#include <string.h>
 -#include <stdio.h>
 -
 -#include <ch.h>
 -
 -static ULONG32 wdguard;
 -static WorkingArea(wdarea, 2048);
 -
 -static ULONG32 cdguard;
 -static WorkingArea(cdarea, 2048);
 -static Thread *cdtp;
 -
 -static t_msg WatchdogThread(void *arg);
 -static t_msg ConsoleThread(void *arg);
 -
 -t_msg TestThread(void *p);
 -
 -void InitCore(void);
 -extern FullDuplexDriver COM1, COM2;
 -
 -#define cprint(msg) chMsgSend(cdtp, (t_msg)msg)
 -
 -/*
 - * Watchdog thread, it checks magic values located under the various stack
 - * areas. The system is halted if something is wrong.
 - */
 -static t_msg WatchdogThread(void *arg) {
 -  wdguard = 0xA51F2E3D;
 -  cdguard = 0xA51F2E3D;
 -  while (TRUE) {
 -
 -    if ((wdguard != 0xA51F2E3D) ||
 -        (cdguard != 0xA51F2E3D)) {
 -      printf("Halted by watchdog");
 -      chSysHalt();
 -    }
 -    chThdSleep(50);
 -  }
 -  return 0;
 -}
 -
 -/*
 - * Console print server done using synchronous messages. This makes the access
 - * to the C printf() thread safe and the print operation atomic among threads.
 - * In this example the message is the zero termitated string itself.
 - */
 -static t_msg ConsoleThread(void *arg) {
 -
 -  while (!chThdShouldTerminate()) {
 -    printf((char *)chMsgWait());
 -    chMsgRelease(RDY_OK);
 -  }
 -  return 0;
 -}
 -
 -static void PrintLineFDD(FullDuplexDriver *sd, char *msg) {
 -
 -  while (*msg)
 -    chFDDPut(sd, *msg++);
 -}
 -
 -static BOOL GetLineFDD(FullDuplexDriver *sd, char *line, int size) {
 -  char *p = line;
 -
 -  while (TRUE) {
 -    short c = chIQGet(&sd->sd_iqueue);
 -    if (c < 0)
 -      return TRUE;
 -    if (c == 4) {
 -      PrintLineFDD(sd, "^D\r\n");
 -      return TRUE;
 -    }
 -    if (c == 8) {
 -      if (p != line) {
 -        chFDDPut(sd, (BYTE8)c);
 -        chFDDPut(sd, 0x20);
 -        chFDDPut(sd, (BYTE8)c);
 -        p--;
 -      }
 -      continue;
 -    }
 -    if (c == '\r') {
 -      PrintLineFDD(sd, "\r\n");
 -      *p = 0;
 -      return FALSE;
 -    }
 -    if (c < 0x20)
 -      continue;
 -    if (p < line + size - 1) {
 -      chFDDPut(sd, (BYTE8)c);
 -      *p++ = (BYTE8)c;
 -    }
 -  }
 -}
 -
 -/*
 - * Example thread, not much to see here. It simulates the CTRL-C but there
 - * are no real signals involved.
 - */
 -static t_msg HelloWorldThread(void *arg) {
 -  int i;
 -  short c;
 -  FullDuplexDriver *sd = (FullDuplexDriver *)arg;
 -
 -  for (i = 0; i < 100; i++) {
 -
 -    PrintLineFDD(sd, "Hello World\r\n");
 -    c = chFDDGetTimeout(sd, 333);
 -    switch (c) {
 -    case -1:
 -      continue;
 -    case -2:
 -      return 1;
 -    case 3:
 -      PrintLineFDD(sd, "^C\r\n");
 -      return 0;
 -    default:
 -      chThdSleep(333);
 -    }
 -  }
 -  return 0;
 -}
 -
 -static BOOL checkend(FullDuplexDriver *sd) {
 -
 -  char * lp = strtok(NULL, " \009"); /* It is not thread safe but this is a demo.*/
 -  if (lp) {
 -    PrintLineFDD(sd, lp);
 -    PrintLineFDD(sd, " ?\r\n");
 -    return TRUE;
 -  }
 -  return FALSE;
 -}
 -
 -/*
 - * Simple command shell thread, the argument is the serial line for the
 - * standard input and output. It recognizes few simple commands.
 - */
 -static t_msg ShellThread(void *arg) {
 -  FullDuplexDriver *sd = (FullDuplexDriver *)arg;
 -  char *lp, line[64];
 -  Thread *tp;
 -  WorkingArea(tarea, 1024);
 -
 -  chIQReset(&sd->sd_iqueue);
 -  chOQReset(&sd->sd_oqueue);
 -  PrintLineFDD(sd, "ChibiOS/RT Command Shell\r\n\n");
 -  while (TRUE) {
 -    PrintLineFDD(sd, "ch> ");
 -    if (GetLineFDD(sd, line, sizeof(line))) {
 -      PrintLineFDD(sd, "\nlogout");
 -      break;
 -    }
 -    lp = strtok(line, " \009"); // Note: not thread safe but it is just a demo.
 -    if (lp) {
 -      if ((stricmp(lp, "help") == 0) ||
 -          (stricmp(lp, "h") == 0) ||
 -          (stricmp(lp, "?") == 0)) {
 -        if (checkend(sd))
 -          continue;
 -        PrintLineFDD(sd, "Commands:\r\n");
 -        PrintLineFDD(sd, "  help,h,? - This help\r\n");
 -        PrintLineFDD(sd, "  exit     - Logout from ChibiOS/RT\r\n");
 -        PrintLineFDD(sd, "  time     - Prints the system timer value\r\n");
 -        PrintLineFDD(sd, "  hello    - Runs the Hello World demo thread\r\n");
 -      }
 -      else if (stricmp(lp, "exit") == 0) {
 -        if (checkend(sd))
 -          continue;
 -        PrintLineFDD(sd, "\nlogout");
 -        break;
 -      }
 -      else if (stricmp(lp, "time") == 0) {
 -        if (checkend(sd))
 -          continue;
 -        sprintf(line, "Time: %d\r\n", chSysGetTime());
 -        PrintLineFDD(sd, line);
 -      }
 -      else if (stricmp(lp, "hello") == 0) {
 -        if (checkend(sd))
 -          continue;
 -        tp = chThdCreate(NORMALPRIO, 0, tarea, sizeof(tarea),
 -                         HelloWorldThread, sd);
 -        if (chThdWait(tp))
 -          break;  // Lost connection while executing the hello thread.
 -      }
 -      else {
 -        PrintLineFDD(sd, lp);
 -        PrintLineFDD(sd, " ?\r\n");
 -      }
 -    }
 -  }
 -  return 0;
 -}
 -
 -static WorkingArea(s1area, 2048);
 -static Thread *s1;
 -EventListener s1tel;
 -
 -static void COM1Handler(t_eventid id) {
 -  t_dflags flags;
 -
 -  if (s1 && chThdTerminated(s1)) {
 -    s1 = NULL;
 -    cprint("Init: disconnection on COM1\n");
 -  }
 -  flags = chFDDGetAndClearFlags(&COM1);
 -  if ((flags & SD_CONNECTED) && (s1 == NULL)) {
 -    cprint("Init: connection on COM1\n");
 -    s1 = chThdCreate(NORMALPRIO, P_SUSPENDED, s1area, sizeof(s1area),
 -                     ShellThread, &COM1);
 -    chEvtRegister(chThdGetExitEventSource(s1), &s1tel, 0);
 -    chThdResume(s1);
 -  }
 -  if ((flags & SD_DISCONNECTED) && (s1 != NULL))
 -    chIQReset(&COM1.sd_iqueue);
 -}
 -
 -static WorkingArea(s2area, 2048);
 -static Thread *s2;
 -EventListener s2tel;
 -
 -static void COM2Handler(t_eventid id) {
 -  t_dflags flags;
 -
 -  if (s2 && chThdTerminated(s2)) {
 -    s2 = NULL;
 -    cprint("Init: disconnection on COM2\n");
 -  }
 -  flags = chFDDGetAndClearFlags(&COM2);
 -  if ((flags & SD_CONNECTED) && (s2 == NULL)) {
 -    cprint("Init: connection on COM2\n");
 -    s2 = chThdCreate(NORMALPRIO, P_SUSPENDED, s2area, sizeof(s1area),
 -                     ShellThread, &COM2);
 -    chEvtRegister(chThdGetExitEventSource(s2), &s2tel, 1);
 -    chThdResume(s2);
 -  }
 -  if ((flags & SD_DISCONNECTED) && (s2 != NULL))
 -    chIQReset(&COM2.sd_iqueue);
 -}
 -
 -static t_evhandler fhandlers[2] = {
 -  COM1Handler,
 -  COM2Handler
 -};
 -
 -/*------------------------------------------------------------------------*
 - * Simulator main, start here your threads, examples inside.              *
 - *------------------------------------------------------------------------*/
 -int main(void) {
 -  EventListener c1fel, c2fel;
 -
 -  InitCore();
 -
 -  // Startup ChibiOS/RT.
 -  chSysInit();
 -
 -  chThdCreate(NORMALPRIO + 2, 0, wdarea, sizeof(wdarea), WatchdogThread, NULL);
 -  cdtp = chThdCreate(NORMALPRIO + 1, 0, cdarea, sizeof(cdarea), ConsoleThread, NULL);
 -
 -  cprint("Console service started on COM1, COM2\n");
 -  cprint("  - Listening for connections on COM1\n");
 -  chFDDGetAndClearFlags(&COM1);
 -  chEvtRegister(&COM1.sd_sevent, &c1fel, 0);
 -  cprint("  - Listening for connections on COM2\n");
 -  chFDDGetAndClearFlags(&COM2);
 -  chEvtRegister(&COM2.sd_sevent, &c2fel, 1);
 -  while (!chThdShouldTerminate())
 -    chEvtWait(ALL_EVENTS, fhandlers);
 -  chEvtUnregister(&COM2.sd_sevent, &c2fel); // Never invoked but this is an example...
 -  chEvtUnregister(&COM1.sd_sevent, &c1fel); // Never invoked but this is an example...
 -  return 0;
 -}
 diff --git a/demos/Win32-MSVS/readme.txt b/demos/Win32-MSVS/readme.txt deleted file mode 100644 index 6025e4879..000000000 --- a/demos/Win32-MSVS/readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -*****************************************************************************
 -** ChibiOS/RT port for x86 into a Win32 process                            **
 -*****************************************************************************
 -
 -** TARGET **
 -
 -The demo runs under any Windows version as an application program. The serial
 -I/O is simulated over TCP/IP sockets.
 -
 -** The Demo **
 -
 -The demo listens on the two serial ports, when a connection is detected a
 -thread is started that serves a small command shell.
 -The demo shows how create/terminate threads at runtime, how listen to events,
 -how ho work with serial ports, how use the messages.
 -You can develop your ChibiOS/RT application using this demo as a simulator
 -then you can recompile it for a different architecture.
 -See demo.c for details.
 -
 -** Build Procedure **
 -
 -The demo was built using the Visual Studio 7, any later version should work.
 diff --git a/demos/Win32-MinGW/chcore.h b/demos/Win32-MinGW/chcore.h index 6bb2664f5..fed88c171 100644 --- a/demos/Win32-MinGW/chcore.h +++ b/demos/Win32-MinGW/chcore.h @@ -45,7 +45,7 @@ typedef struct {  #define SETUP_CONTEXT(workspace, wsize, pf, arg)                        \
  {                                                                       \
 -  BYTE8 *esp = (BYTE8 *)workspace + wsize;                              \
 +  uint8_t *esp = (uint8_t *)workspace + wsize;                          \
    APUSH(esp, arg);                                                      \
    APUSH(esp, threadstart);                                              \
    esp -= sizeof(struct intctx);                                         \
 @@ -70,7 +70,7 @@ typedef struct {                                      sizeof(struct intctx) +             \
                                      (n) +                               \
                                      INT_REQUIRED_STACK)
 -#define WorkingArea(s, n) ULONG32 s[UserStackSize(n) >> 2];
 +#define WorkingArea(s, n) uint32_t s[UserStackSize(n) >> 2];
  #define IDLE_THREAD_STACK_SIZE 16384
  t_msg _IdleThread(void *p);
 diff --git a/demos/Win32-MinGW/chtypes.h b/demos/Win32-MinGW/chtypes.h index 2ac219148..c8a1dc69c 100644 --- a/demos/Win32-MinGW/chtypes.h +++ b/demos/Win32-MinGW/chtypes.h @@ -20,27 +20,21 @@  #ifndef _CHTYPES_H_
  #define _CHTYPES_H_
 -/*
 - * Generic types often dependant on the compiler.
 - */
 -#define BOOL        char
 -#define BYTE8       unsigned char
 -#define SBYTE8      char
 -#define WORD16      short
 -#define UWORD16     unsigned short
 -#define LONG32      int
 -#define ULONG32     unsigned int
 -
 -typedef BYTE8       t_tmode;
 -typedef BYTE8       t_tstate;
 -typedef UWORD16     t_tid;
 -typedef ULONG32     t_prio;
 -typedef LONG32      t_msg;
 -typedef LONG32      t_eventid;
 -typedef ULONG32     t_eventmask;
 -typedef ULONG32     t_time;
 -typedef LONG32      t_cnt;
 -typedef ULONG32     t_size;
 +#if !defined(_STDINT_H) && !defined(__STDINT_H_)
 +#include <stdint.h>
 +#endif
 +
 +typedef int8_t          t_bool;
 +typedef uint8_t         t_tmode;
 +typedef uint8_t         t_tstate;
 +typedef uint16_t        t_tid;
 +typedef uint32_t        t_prio;
 +typedef int32_t         t_msg;
 +typedef int32_t         t_eventid;
 +typedef uint32_t        t_eventmask;
 +typedef uint32_t        t_time;
 +typedef int32_t         t_cnt;
 +typedef uint32_t        t_size;
  #define INLINE      inline
 diff --git a/demos/Win32-MinGW/demo.c b/demos/Win32-MinGW/demo.c index acf17e7fd..0b646a50b 100644 --- a/demos/Win32-MinGW/demo.c +++ b/demos/Win32-MinGW/demo.c @@ -22,10 +22,10 @@  #include <ch.h>
 -static ULONG32 wdguard;
 +static uint32_t wdguard;
  static WorkingArea(wdarea, 2048);
 -static ULONG32 cdguard;
 +static uint32_t cdguard;
  static WorkingArea(cdarea, 2048);
  static Thread *cdtp;
 @@ -78,7 +78,7 @@ static void PrintLineFDD(FullDuplexDriver *sd, char *msg) {      chFDDPut(sd, *msg++);
  }
 -static BOOL GetLineFDD(FullDuplexDriver *sd, char *line, int size) {
 +static t_bool GetLineFDD(FullDuplexDriver *sd, char *line, int size) {
    char *p = line;
    while (TRUE) {
 @@ -91,9 +91,9 @@ static BOOL GetLineFDD(FullDuplexDriver *sd, char *line, int size) {      }
      if (c == 8) {
        if (p != line) {
 -        chFDDPut(sd, (BYTE8)c);
 +        chFDDPut(sd, (uint8_t)c);
          chFDDPut(sd, 0x20);
 -        chFDDPut(sd, (BYTE8)c);
 +        chFDDPut(sd, (uint8_t)c);
          p--;
        }
        continue;
 @@ -106,8 +106,8 @@ static BOOL GetLineFDD(FullDuplexDriver *sd, char *line, int size) {      if (c < 0x20)
        continue;
      if (p < line + size - 1) {
 -      chFDDPut(sd, (BYTE8)c);
 -      *p++ = (BYTE8)c;
 +      chFDDPut(sd, (uint8_t)c);
 +      *p++ = (uint8_t)c;
      }
    }
  }
 @@ -140,7 +140,7 @@ static t_msg HelloWorldThread(void *arg) {    return 0;
  }
 -static BOOL checkend(FullDuplexDriver *sd) {
 +static t_bool checkend(FullDuplexDriver *sd) {
    char * lp = strtok(NULL, " \009"); /* It is not thread safe but this is a demo.*/
    if (lp) {
  | 
