From 8cd9954ec674d2fe29620c292355562d554c5fd4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 21 Feb 2010 11:35:10 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1652 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/Posix/console.c | 126 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 os/hal/platforms/Posix/console.c (limited to 'os/hal/platforms/Posix/console.c') diff --git a/os/hal/platforms/Posix/console.c b/os/hal/platforms/Posix/console.c new file mode 100644 index 000000000..737cf92bf --- /dev/null +++ b/os/hal/platforms/Posix/console.c @@ -0,0 +1,126 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 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 . +*/ + +/** + * @file console.c + * @brief Simulator console driver code. + * @{ + */ + +#include + +#include "ch.h" +#include "console.h" + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/** + * @brief Console driver 1. + */ +BaseChannel CD1; + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + + +static size_t writes(void *ip, const uint8_t *bp, size_t n) { + size_t ret; + + (void)ip; + ret = fwrite(bp, 1, n, stdout); + fflush(stdout); + return ret; +} + +static size_t reads(void *ip, uint8_t *bp, size_t n) { + + (void)ip; + return fread(bp, 1, n, stdin); +} + +static bool_t putwouldblock(void *ip) { + + (void)ip; + return FALSE; +} + +static bool_t getwouldblock(void *ip) { + + (void)ip; + return TRUE; +} + +static msg_t putt(void *ip, uint8_t b, systime_t time) { + + (void)ip; + (void)time; + fputc(b, stdout); + fflush(stdout); + return RDY_OK; +} + +static msg_t gett(void *ip, systime_t time) { + + (void)ip; + (void)time; + return fgetc(stdin); +} + +static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) { + size_t ret; + + (void)ip; + (void)time; + ret = fwrite(bp, 1, n, stdout); + fflush(stdout); + return ret; +} + +static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) { + + (void)ip; + (void)time; + return fread(bp, 1, n, stdin); +} + +static const struct BaseChannelVMT vmt = { + writes, reads, putwouldblock, getwouldblock, putt, gett, writet, readt +}; + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +void conInit(void) { + + CD1.vmt = &vmt; +} + +/** @} */ -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/Posix/console.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/hal/platforms/Posix/console.c') diff --git a/os/hal/platforms/Posix/console.c b/os/hal/platforms/Posix/console.c index 737cf92bf..4f29b7900 100644 --- a/os/hal/platforms/Posix/console.c +++ b/os/hal/platforms/Posix/console.c @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/Posix/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/platforms/Posix/console.c') diff --git a/os/hal/platforms/Posix/console.c b/os/hal/platforms/Posix/console.c index 4f29b7900..ed62545fb 100644 --- a/os/hal/platforms/Posix/console.c +++ b/os/hal/platforms/Posix/console.c @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/Posix/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/platforms/Posix/console.c') diff --git a/os/hal/platforms/Posix/console.c b/os/hal/platforms/Posix/console.c index ed62545fb..43681af9b 100644 --- a/os/hal/platforms/Posix/console.c +++ b/os/hal/platforms/Posix/console.c @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From 853216256ad4cdacf5f94edb7d6b738c6be165a1 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 30 Mar 2013 10:32:37 +0000 Subject: Relicensing parts of the tree under the Apache 2.0 license. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5521 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/Posix/console.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'os/hal/platforms/Posix/console.c') diff --git a/os/hal/platforms/Posix/console.c b/os/hal/platforms/Posix/console.c index 43681af9b..e6e15395b 100644 --- a/os/hal/platforms/Posix/console.c +++ b/os/hal/platforms/Posix/console.c @@ -1,21 +1,17 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio - This file is part of ChibiOS/RT. + 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 - 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. + http://www.apache.org/licenses/LICENSE-2.0 - 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 . + 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. */ /** -- cgit v1.2.3 From d9f59f37daebf16abaca81dfabba1c198b5d2f33 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 26 May 2013 07:29:35 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5757 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/Posix/console.c | 1 + 1 file changed, 1 insertion(+) (limited to 'os/hal/platforms/Posix/console.c') diff --git a/os/hal/platforms/Posix/console.c b/os/hal/platforms/Posix/console.c index e6e15395b..f2e79323c 100644 --- a/os/hal/platforms/Posix/console.c +++ b/os/hal/platforms/Posix/console.c @@ -23,6 +23,7 @@ #include #include "ch.h" +#include "hal.h" #include "console.h" /*===========================================================================*/ -- cgit v1.2.3 From 386a2bf39039dc2a2723058921482b7cd3cb9e77 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 26 May 2013 07:36:40 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5759 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/Posix/console.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'os/hal/platforms/Posix/console.c') diff --git a/os/hal/platforms/Posix/console.c b/os/hal/platforms/Posix/console.c index f2e79323c..dbbfbf661 100644 --- a/os/hal/platforms/Posix/console.c +++ b/os/hal/platforms/Posix/console.c @@ -43,8 +43,7 @@ BaseChannel CD1; /* Driver local functions. */ /*===========================================================================*/ - -static size_t writes(void *ip, const uint8_t *bp, size_t n) { +static size_t write(void *ip, const uint8_t *bp, size_t n) { size_t ret; (void)ip; @@ -53,22 +52,26 @@ static size_t writes(void *ip, const uint8_t *bp, size_t n) { return ret; } -static size_t reads(void *ip, uint8_t *bp, size_t n) { +static size_t read(void *ip, uint8_t *bp, size_t n) { (void)ip; return fread(bp, 1, n, stdin); } -static bool_t putwouldblock(void *ip) { +static msg_t put(void *ip, uint8_t b) { (void)ip; - return FALSE; + + fputc(b, stdout); + fflush(stdout); + return RDY_OK; } -static bool_t getwouldblock(void *ip) { +static msg_t get(void *ip) { (void)ip; - return TRUE; + + return fgetc(stdin); } static msg_t putt(void *ip, uint8_t b, systime_t time) { @@ -105,7 +108,8 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) { } static const struct BaseChannelVMT vmt = { - writes, reads, putwouldblock, getwouldblock, putt, gett, writet, readt + write, read, put, get, + putt, gett, writet, readt }; /*===========================================================================*/ -- cgit v1.2.3