Commit graph

50 commits

Author SHA1 Message Date
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Jukka Rissanen 31ec75fca3 modem: shell: Add info command
Add an information command that currently will only prints
GSM muxing status.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-17 10:15:54 +03:00
Jukka Rissanen 420b195b5e drivers: console: uart_mux: Initial UART muxing support
Create support for muxed UARTs which are attached to a real
UART and which use GSM 07.10 muxing protocol to create virtual
channels that can be run on top of the real UART.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-17 10:15:54 +03:00
Kumar Gala 140a8d0c8a console: Remove deprecated function console_register_line_input
console_register_line_input has been deprecated for at least 2 releases
so we can now remove it.  Remove native_stdin_register_input that is
associated with console_register_line_input.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-18 19:14:25 -05:00
Peter Bigot 6554a5e5b6 include: rearrange for standard use of extern "C" in various headers
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.

The inclusion of the generated syscall files is placed outside the
extern "C" block as the generated file has its own extern "C" block.

Background from issue #17997:

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-08-13 18:00:31 +02:00
Anas Nashif 7435e5e089 cleanup: include/: move ring_buffer.h to sys/ring_buffer.h
move ring_buffer.h to sys/ring_buffer.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Nicolas Pitre 659fa0d57d lifo/fifo: first word is not always first 4 bytes
The first word is used as a pointer, meaning it is 64 bits on 64-bit
systems. To reserve it, it has to be either a pointer, a long, or an
intptr_t. Not an int nor an u32_t.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-06-26 09:08:42 -04:00
Anas Nashif 83ceb4953a net: telnet: remove obsolete code
Remove obsolote telnet console code. We now have a proper shell backend
for telnet.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 10:26:27 -04:00
Flavio Ceolin 95eb2b4fed include: Use macro BIT for shift operations
Use a macro BIT when dealing with bit shift operations.

MISRA-C rule 10.1

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2019-03-26 14:31:29 -04:00
Kumar Gala dafad70b96 console: Remove CONFIG_WEBSOCKET_CONSOLE code
Websocket was removed in 1cba0161ed so
remove dead Kconfig references to CONFIG_WEBSOCKET_CONSOLE and
associated dead code/files.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-11 22:29:58 -05:00
Alberto Escolar Piedras 553d43002f drivers: console: native: header fix
posix_flush_stdout() must be provided by any board
using CONFIG_NATIVE_POSIX_CONSOLE, not just by those using
CONFIG_NATIVE_POSIX_STDOUT_CONSOLE

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-10-15 09:36:37 -04:00
Flavio Ceolin 4a211ec241 include: Add missing headers guard
Add missing headers guard

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Jukka Rissanen ead9cd409c net: websocket: Add console support
Add console driver that allows console session to be transferred
over a websocket connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-03-15 15:17:36 +02:00
Christopher Collins 14735116d1 subsys: mgmt: UART transport for SMP (mcumgr).
Add a UART driver dedicated to transporting mcumgr SMP requests and
responses.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-20 22:07:52 +01:00
Christopher Collins 76bf5646d5 subsys: mgmt: Shell transport for SMP (mcumgr).
Enable the shell to transport mcumgr SMP requests and responses.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-20 22:07:52 +01:00
Alberto Escolar Piedras e3f727cc6e native: added stdin handling for shell
Now the native console driver also handles stdin
so we can drive the shell from the command line,
a pipe or a file

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-02-02 07:48:46 -08:00
Anas Nashif e2122cbf89 lib: move ring_buffer from misc/ to lib/
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-15 20:02:01 -05:00
Andrew Boie c5c104f91e kernel: fix k_thread_stack_t definition
Currently this is defined as a k_thread_stack_t pointer.
However this isn't correct, stacks are defined as arrays. Extern
references to k_thread_stack_t doesn't work properly as the compiler
treats it as a pointer to the stack array and not the array itself.

Declaring as an unsized array of k_thread_stack_t doesn't work
well either. The least amount of confusion is to leave out the
pointer/array status completely, use pointers for function prototypes,
and define K_THREAD_STACK_EXTERN() to properly create an extern
reference.

The definitions for all functions and struct that use
k_thread_stack_t need to be updated, but code that uses them should
be unchanged.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-10-17 08:24:29 -07:00
Andrew Boie 507852a4ad kernel: introduce opaque data type for stacks
Historically, stacks were just character buffers and could be treated
as such if the user wanted to look inside the stack data, and also
declared as an array of the desired stack size.

This is no longer the case. Certain architectures will create a memory
region much larger to account for MPU/MMU guard pages. Unfortunately,
the kernel interfaces treat both the declared stack, and the valid
stack buffer within it as the same char * data type, even though these
absolutely cannot be used interchangeably.

We introduce an opaque k_thread_stack_t which gets instantiated by
K_THREAD_STACK_DECLARE(), this is no longer treated by the compiler
as a character pointer, even though it really is.

To access the real stack buffer within, the result of
K_THREAD_STACK_BUFFER() can be used, which will return a char * type.

This should catch a bunch of programming mistakes at build time:

- Declaring a character array outside of K_THREAD_STACK_DECLARE() and
  passing it to K_THREAD_CREATE
- Directly examining the stack created by K_THREAD_STACK_DECLARE()
  which is not actually the memory desired and may trigger a CPU
  exception

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-08-01 16:43:15 -07:00
Andrew Boie b52a62b561 ipm_console_receiver: use k_thread_create()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Kumar Gala cc334c7273 Convert remaining code to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.  This handles the remaining includes and kernel, plus
touching up various points that we skipped because of include
dependancies.  We also convert the PRI printf formatters in the arch
code over to normal formatters.

Jira: ZEP-2051

Change-Id: Iecbb12601a3ee4ea936fd7ddea37788a645b08b0
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 11:38:23 -05:00
Paul Sokolovsky 542c2b93d0 subsys: console: Add pull-style console API support.
This change introduces console_getchar() and console_getline() API
calls which can be used to get pending console input (either one
char or whole line), or block waiting for one. In this regard, they
are similar to well-known ANSI C function getchar/gets/fgets, and
are intended to ease porting of existing applications to Zephyr, and
indeed, these functions (shaped as an external module) are already
used by few applications.

The implementation of the functions is structured as a new "console"
subsystem. The intention is that further generic console code may be
pulled there instead of being in drivers/console/. Besides the
functions themselves, initialization code and sample applications
are included.

At this time, there're may limitations of how these functions can
be used. For example, console_getchar() and console_getline() are
mutually exclusive, and both are incompatible with callback
(push-style) console API (and e.g. with console shell subsystem
which uses this API). Again, the intention is to make a first step
towards refactoring console subsystem to allow more flexible
real-world usage, better reusability and composability.

Change-Id: I3f4015bb5b26e0656f82f428b11ba30e980d25a0
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-01 20:44:17 +00:00
Andrew Boie 3cc4d41438 ipm_console: add Kconfig for receiver stack size
Change-Id: I27c1189e3bf87b4ea3dc06d38f63cab21663697b
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-03-06 16:58:20 +00:00
Tomasz Bursztyka 1d9402b3e3 drivers/console/telnet: Provide minimal input handling.
Telnet "Interpret As Command" (IAC) code is ignored.

Change-Id: I882397389d77b8adfcbce62fbd9654c0b0412ae3
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
Tomasz Bursztyka 2f1af492ee console/shell: Switch to generic console input
Let's use the generic console input type now. This will be useful for
other console input drivers such as telnet.

Change-Id: I787a1e9d86481d5f8c4803453726d9042a89dea4
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
Tomasz Bursztyka 3e65158936 drivers/console: Making console input generic
Input line length can be modified via Kconfig.

Change-Id: I3423fce9814e04b11d11e5d391f85fe1efbe8d17
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Qiu Peiyang f38dc9995e uart: fix typo in uart_console.h
Fix typo introduced by commit 6b2443e("console: Fix warnings
related to the use of deprecated APIs")

Change-Id: I6b4db8ba781fecae4413f473001f40ff53c765f0
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2016-11-30 15:05:19 +00:00
Anas Nashif 2367df8d59 drivers: update ipm driver to use unified kernel
Move away from legacy APIs and use unified kenrel instead.

Change-Id: Icae86beec66df1b041405cbe3455913630fc8ad1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-11-13 13:53:53 +00:00
Luiz Augusto von Dentz 6b2443e99b console: Fix warnings related to the use of deprecated APIs
This fixes the warnings related to the use of deprecated APIs
converting them to use the unified version.

Change-Id: I76d076de27ecdae4af46abf4baac68e2cc1313c0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-11-11 14:50:58 +02:00
Marcus Shawcroft 1bc999cb8d drivers/uart: Refactor UART input hook.
This refactor is in preparation for making driver API structures
const.

The console driver provides a mechanism to install an input and an
output hook function.  These are primarily used by the onboard
gdb-server.  The output hook is entirely implemented within the
console driver.

The input hook is partially implemented in the top of the uart driver
and within the console driver.  The hook function itself is installed
in the uart API structure, but is invoked only by the console driver.

Installing the hook function directly into the uart API structure
prevents the API structure being const.  There are two approaches to
fixing this:

1) Implement setting of the input hook in the same way as
uart_irq_callback_set().

2) Move the input hook entirely to the console driver.

We implement the latter.  This approach has two benefits, first it
removes the need for every uart driver to implement the behaviour and
second, the current placement of the callback function in the uart API
seems odd given that the callback is only invoked by the console
driver, never by a uart driver.

Change-Id: I258b312d3055df1c2bdeb896bd4f4f39c40838f7
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 11:31:08 +00:00
Andrew Boie 926a368991 ipm_console: rate-limit to avoid losing messages
These console messages are for debugging and if sent too
rapidly, could be discarded. This was causing false positives on
test cases which rely on console output to determine success or
failure.

Issue: ZEP-704
Change-Id: I5a86c761311cde90f295cd2e65f2e70608f875fa
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-17 18:04:37 +00:00
Szymon Janc d7e8fd0446 console: Add support for commands completion
This allows to register callback that will be called to
perform command completion.

Change-Id: Ide7a0427d9b8bb4dd8cfc0995ef2567b32e89632
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-05-26 12:02:51 +00:00
Benjamin Walsh 0ff5d37a4a console: add hook for debug server to handle outgoing characters
A debug server might want to redirect outgoing characters on the console
to another output if it piggybacks on the serial line normally reserved
for the console.

Change-Id: I534f5b35456306940a3926f52fe5cce2d5c94da4
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-04-16 05:29:20 +00:00
Szymon Janc 1b0e961ef2 Fix uart_pipe_send documentation
This function doesn't return number of bytes sent but error code.

Change-Id: Ife5e4d3957226ce2b4283b5d229095db2ac375dc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-08 13:53:26 +00:00
Daniel Leung e643cede3a uart: add ISR callback mechanism for UART drivers
The peripherals utilizing UART were required to register their own
ISR rountines. This means that all those peripherals drivers need
to know which IRQ line is attached to a UART controller, and all
the other config values required to register a ISR. This causes
scalibility issue as every board and peripherals have to define
those values.

Another reason for this patch is to support virtual serial ports.
Virtual serial ports do not have physical interrupt lines to
attach, and thus would not work.

This patch adds a simple callback mechanism, which calls a function
when UART interrupts are triggered. The low level plumbing still needs
to be done by the peripheral drivers, as these drivers may need to
access low level capability of UART to function correctly. This simply
moves the interrupt setup into the UART drivers themselves. By doing
this, the peripheral drivers do not need to know all the config values
to properly setup the interrupts and attaching the ISR. One drawback
is that this adds to the interrupt latency.

Note that this patch breaks backward compatibility in terms of
setting up interrupt for UART controller. How to use UART is still
the same.

This also addresses the following issues:

() UART driver for Atmel SAM3 currently does not support interrupts.
   So remove the code from vector table. This will be updated when
   there is interrupt support for the driver.
() Corrected some config options for Stellaris UART driver.

This was tested with samples/shell on Arduino 101, and on QEMU
(Cortex-M3 and x86).

Origin: original code
Change-Id: Ib4593d8ccd711f4e97d388c7293205d213be1aec
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-05 13:37:57 +00:00
Peter Mitsis a0e4568760 c++: Add extern "C" { } block to header files
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ source files.

Change-Id: Ia4db0c36a5dac5d3de351184a297d2af0df64532
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:22 -05:00
Andrew Boie 3589695508 ipi: rename to ipm
To many people, IPI connotes inter-processor interrupts on SMP
systems. Rename this to IPM, or Inter-Processor Mailboxes.

Change-Id: I032815e23c69a8297c0a43992132441c240fb71e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:04 -05:00
Johan Hedberg 7ad2d474d8 drivers/console: shell: Decrease maximum line length from 1024 to 256
It's very rare to have lines exceeding 100 characters (default console
width being 80) so 1024 is quite overkill. Even 256 is probably more
than anyone will need any time soon, but if that becomes an issue this
define can be converted to a Kconfig option in the future.

Change-Id: If5fd324b17a0e8ef7b39ea7cc6624739d0241cac
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:58 -05:00
Peter Mitsis 42bb6227dc doc: Change "None" return value to "N/A"
Improves documentation consistency by using "N/A" instead of "None"
when the routine does not return a value.

Change-Id: I429a159b3037742cbc431db0cb4828ab9d6d35c3
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:53 -05:00
Szymon Janc c0baad2262 Rename simple UART driver to pipe UART
Original name was too generic and confusing. This patch renames
driver to pipe UART and moves it to console drivers folder. Kconfig
destription is also improved.

Change-Id: I716fdbf7d636bbdc03b0fce27a59fd866f473246
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:52 -05:00
Andrei Emeltchenko 71a19117d6 Bluetooth: Rename __unused to compile with newlib
__unused is define in sys/cdefs.h when building against newlib.

Change-Id: I0fad81dc91e1eb91368b5b3370e3fbb0fb7ba4a9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:24:44 -05:00
Dan Kalowsky da67b29569 checkpatch: warning - block_comment_style
Change-Id: I6da43e41f9c6efee577b70513ec368ae3cce0144
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Andrew Boie 2a1e4266e8 IPI console driver with test case
This introduces a generic driver set for console messages routed over
inter-processor interrupt (IPI) channels. These drivers bind to a
low-level IPI driver instance for the actual transport of messages.

ipi_console_sender installs printk and/or stdout hooks to forward
messages over IPI. There is currently no buffering on the sending side.

ipi_console_receiver installs an IPI callback which stashes incoming
characters into a ring buffer, which is monitored by a nanokernel
fiber. The fiber buffers the characters on a per-line basis and sends
them to either printk or stdout. Multiple instances of this driver
may be created in case you need to receive console data from multiple
CPUs.

Change-Id: Icebc110794fbe040f975101cd2ae6e78fb38645a
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:24:17 -05:00
Daniel Leung ad2d29689e console: uart_console: decouple uart console init from UART init
With this, the UART console has its own initialization which is not
dependent on UART init routines.

This will allow the app to utilize all UARTs for other purposes,
instead of always reserving one for console. Future patch
will enable this choice.

Note that the console init is effectively demoted to pure_init
from pure_early_init. The UART console depends on UART being
initialized, but there is no deferred init at this point.
So this initializes the console a bit later than UARTs,
simply to make sure the UART is initialized before using it.
Once there is a mechanism for some type of deferred initialization,
the UART console init can be promoted back to pure_early.

Change-Id: Iba95197b13384cb1a46e34c78638348b7a0bec8c
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Allan Stephens bb9ab0322e Eliminate unnecessary references to cpu.h and cputype.h
Gets rid of places where there is no need to include these files
at all, or places where these files are being indirectly included
due to the inclusion of nanokernel.h.

Change-Id: I7b58148af454b977830c00a6b519a78d0595603b
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:14 -05:00
Andrei Emeltchenko 879541a918 console: Refactor serial console interface
Make serial console interface more robust. Enables interrupts only
when registering input, all memory is managed inside application.
Interface to application is changed to have two fifo queues. One
queue is a free line slots and another queue is keeping entered
lines. This way memory for lines is managed inside application which
provides free lines queue. It is also simpler to manage entered
lines by sleeping on fifo_get on app layer.

Change-Id: I4776c03eddd1e7d880df3b902bd48f5f2c901cad
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Tomasz Bursztyka ae09a48a7e console: Put the public API header in the right location
Only moving the header from drivers/console/uart_console.h to
include/drivers/console/uart_console.h so source file did not need to be
changed, only the defs.objs files to look into include/drivers/console.

Change-Id: I585e16b50d9ffecf01ca9225e80f0e101f62ee4c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:13:48 -05:00