summaryrefslogtreecommitdiffstats
path: root/common/ratp
Commit message (Collapse)AuthorAgeFilesLines
* console: fix out-of-bounds read in dputc(/dev/*, ...)Ahmad Fatoum2019-09-021-7/+5
| | | | | | | | | | | | | | | | | | Trying to output a single character via echo -a /dev/serial0-1 currently results in garbage output after the newline, because console.c's fops_write discards the buffer length and passes the buffer to (struct cdev)::puts which only handles NUL-terminated strings. Fix this by amending (struct cdev)::puts with a new nbytes parameter, which is correctly propagated. All this functions now return at most the nbytes parameter they were passed in. This fixes __console_puts, which used to count new lines twice in its return value. Fixes: b4f55fcf35 ("console: expose consoles in devfs") Cc: Bastian Krause <bst@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: fix use of %hu for printing intAhmad Fatoum2019-08-301-1/+1
| | | | | | | | | While each of path_size and data_size is 16 bit in size, their sum may exceed this. Also the type of the resulting expression is an int, thus change the format specifier accordingly. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crc: import crc_itu_t() from kernelSascha Hauer2019-03-041-1/+1
| | | | | | | | Our cyc_crc16() function is the same function as crc_itu_t() in the Linux kernel. Import and use crc_itu_t() from the Kernel for consistency. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/lseek'Sascha Hauer2019-02-131-4/+5
|\
| * commands: Get rid of mem_rw_bufAndrey Smirnov2019-01-291-4/+5
| | | | | | | | | | | | | | | | | | | | There doesn't seem to be any good reason for all of the memory commands (md, mw, etc.) to rely on a shared pre-allocated buffer anymore. So, to simplify things, drop the shared buffer and adjust all of the utilites to allocate needed memory. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: Introduce MAP_FAILED and replace ad-hoc constants with itAndrey Smirnov2019-01-161-1/+1
|/ | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: fix compile warningsOleksij Rempel2018-10-231-1/+1
| | | | | Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ratp'Sascha Hauer2018-10-098-32/+483
|\
| * ratp: fix incorrect whitespaces in method callsAleksander Morgado2018-09-174-15/+15
| | | | | | | | | | | | | | | | This is a simple coding style fix to avoid the whitespace before the open-parenthesis in method calls. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: use pr_ macros to print messagesAleksander Morgado2018-09-173-13/+19
| | | | | | | | | | | | | | | | | | Following suggestions in other patch reviews, the RAPT commands are updated to use pr_err() instead of plain printf() to report errors to the user. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: use __packed instead of the full formAleksander Morgado2018-09-173-5/+5
| | | | | | | | | | | | | | | | Just a minor coding style change to follow the suggestions given in patch reviews for other RATP commands. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: implement support for GPIO commandsAleksander Morgado2018-09-173-1/+154
| | | | | | | | | | | | | | | | Introduce three new RATP commands that allow getting and setting GPIO values as well as configuring the direction of the GPIO pins. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: implement i2c read/write supportAleksander Morgado2018-09-173-0/+292
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce two new RATP commands that allow running i2c read/write operations, very similar in format to the already existing md/mw RATP commands. The messages are defined with a fixed 16-bit long register field, but it will only be treated as a 16-bit address if I2C_FLAG_WIDE_ADDRESS is set in the message flags field. If this flag is unset, the start register address is assumed 8-bit long. If the message includes the I2C_FLAG_MASTER_MODE flag, the start register field is ignored and a i2c master send/receive operation is performed. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ratp: select CMDLINE_EDITINGClément Leger2018-09-261-0/+1
|/ | | | | | | | ratp seems to send special characters which are not handle correctly without CDMLINE_EDITING. Without this config, commands run via ratp will have an erratic behavior and/or incorrect output. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: new reset commandAleksander Morgado2018-03-012-0/+56
| | | | | | | | E.g.: $ ./bbremote -v --port /dev/ttyUSB2 reset Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: new md and mw commandsAleksander Morgado2018-03-013-0/+377
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces support for running the md and mw commands using the binary interface provided by RATP. This allows clients to read and write memory files without needing to do custom string parsing on the data returned by the console 'md' and 'mw' operations. The request and response messages used for these new operations are structured in the same way: * An initial fixed-sized section includes the fixed-sized variables (e.g. integers), as well as the size and offset of the variable-length variables. * After the initial fixed-sized section, the buffer is given, which contains the variable-length variables in the offsets previously defined and with the size previously defined. The message also defines separately the offset of the buffer w.r.t. the start of the message. The endpoint reading the message will use this information to decide where the buffer starts. This allows to extend the message format in the future without needing to break the message API, as new fields can be appended to the fixed-sized section as long as the buffer offset is also updated to report the new position of the buffer. E.g.: $ ./bbremote --port /dev/ttyUSB2 md /dev/pic_eeprom_rdu 0x107 5 0000000000 $ ./bbremote --port /dev/ttyUSB2 mw /dev/pic_eeprom_rdu 0x107 0102030405 5 bytes written $ ./bbremote --port /dev/ttyUSB2 md /dev/pic_eeprom_rdu 0x107 5 0102030405 $ ./bbremote --port /dev/ttyUSB2 mw /dev/pic_eeprom_rdu 0x107 0000000000 5 bytes written $ ./bbremote --port /dev/ttyUSB2 md /dev/pic_eeprom_rdu 0x107 5 0000000000 Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: use xstrndup() instead of a custom xmemdup_add_zero()Aleksander Morgado2018-03-011-12/+1
| | | | | | | | The console operations done via RATP expect strings, so just use xstrndup() instead of defining a custom method. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: implement getenv as a standard ratp commandAleksander Morgado2018-03-013-30/+52
| | | | | | | | Also, use xstrndup() instead of the custom xmemdup_add_zero() as we're working with strings anyway. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: implement ping as a standard ratp commandAleksander Morgado2018-03-013-24/+41
| | | | | Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: allow building without full console supportAleksander Morgado2018-03-011-2/+5
| | | | | | | | | | | | | Make CONFIG_RATP a selectable config option, so that the user can enable RATP support without explicitly needing to enable the full console support over RATP (e.g. only for RATP FS or built-in command support). The full console can still be explicitly enabled with CONFIG_CONSOLE_RATP. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: moved logic to its own subdirectoryAleksander Morgado2018-03-013-0/+559
We are going to add new RATP command implementations in separate files within this subdirectory. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>