39 Commits

Author SHA1 Message Date
Konrad Dybcio
672eeb89c3 Add protocol.md 2024-04-25 17:20:17 +02:00
Dmitry Baryshkov
f4e95f6f0c Merge pull request #72 from lumag/laurent
laurent: driver for KernelChip Laurent family of relays
2024-04-08 23:09:06 +03:00
Dmitry Baryshkov
8f668bde64 laurent: driver for KernelChip Laurent family of relays
Add support for the KernelChip Laurent-2 / Laurent-5 / Laurent-112 /
Laurent-128 network-controlled relay arrays.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:20:12 +02:00
Konrad Dybcio
798a76ad62 Merge pull request #71 from lumag/cdba-power
cdba-power: add tool to control power-on/-off
2024-03-30 17:06:41 +01:00
Dmitry Baryshkov
ca5f95d6cd cdba-power: add power-on/-off tool
Add simple tool reusing CDBA code to power boards on and off.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:19 +02:00
Dmitry Baryshkov
762879fd0c device: add support for leaving device powered
For some devices it might be desirable to leave device powered on after
the cdba exits (e.g. to run some long-running tests). Add the
'power_always_on' option that tells cdba server to leave device powered
on after exiting and to toggle power (to reset the device) when
connecting.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:19 +02:00
Dmitry Baryshkov
62dc594cb1 device: split fastboot_open from device_open
Create new function calling fastboot_open so that device_open doesn't
have dependency on the fastboot_ops or udev.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:19 +02:00
Dmitry Baryshkov
2f1caa28c0 tty: split tty_open to a separate file
Split the function tty_open() to a separate file.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:19 +02:00
Dmitry Baryshkov
f6bd2d01d7 watch: split implementation to aseparate file
Split CDBA's watching code to a separate file.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:19 +02:00
Dmitry Baryshkov
bde90b4a15 cdba: replace licence headers with SPDX identifiers
Replace all license headers with the SPDX-License-Identitier headers to
follow the current recommendations.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:19 +02:00
Dmitry Baryshkov
b6c6807add drivers: move device / console backends to separte dir
In order to stop clobbering the root directory, move all device and
console backends to drivers/ subdir.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2024-03-30 18:06:17 +02:00
Dmitry Baryshkov
1da135b08e Merge pull request #70 from niej/readme-quit-session
README: add cmd to quit console and close session
2024-03-13 05:51:33 +02:00
Jun Nie
efd1b44e74 README: add cmd to quit console and close session
Signed-off-by: Jun Nie <jun.nie@linaro.org>
2024-03-13 10:01:27 +08:00
Dmitry Baryshkov
baa48a82c2 Merge pull request #69 from calebccff/ppps-segfault
ppps: check if ppps3_path is valid
2024-03-12 21:45:17 +02:00
Caleb Connolly
98b4aa893a ppps: check if ppps3_path is valid
funny joke about steel + water or something

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2024-02-09 22:51:50 +00:00
Konrad Dybcio
d678216fd7 Merge pull request #66 from 0xB0D/master
Implement fastboot continue when omitting boot img from cdba command line
2024-01-17 11:12:13 +01:00
Bryan O'Donoghue
68ca7e49b4 cdba: Default to fastboot continue if image is omitted
Add the ability to omit the image from the cdba call. In this case default
to "fastboot continue" on the cdba-server side.

Regular booting continues to work like this:
cdba -b db410c -h benchtop-cdba ./qlt-kernel/build/square_5.x-tracking/boot_t2a.img

New option to boot the default image a proxy for "fastboot continue"
cdba -b db410c -h benchtop-cdba

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
2024-01-17 02:09:05 +00:00
Bryan O'Donoghue
30e6838a12 cdba-server: Implement fastboot continue
Add cdba-server side support for "fastboot continue" which allows
fastboot to continue its default boot process.

I find it useful to setup my boards with an additional SD card which I
frequently use the default image on eMMC to chroot to and populate
modules, rebooting into fastboot and subsequently booting via fastboot
a rootfs on the SD card.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
2024-01-17 02:08:44 +00:00
Dmitry Baryshkov
f9c4d71650 Merge pull request #62 from krzk/ftdi-ci
ci: switch to new libftdi on Arch Linux
2023-12-10 23:48:27 +02:00
Krzysztof Kozlowski
266d885cde ci: switch to new libftdi on Arch Linux
Use latest (not compat) version of libftdi in install scripts for Arch
Linux.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-12-10 22:45:30 +01:00
Dmitry Baryshkov
4a38c0e8e1 Merge pull request #61 from krzk/cdba-server-info
Cdba server info
2023-12-10 23:35:56 +02:00
Krzysztof Kozlowski
316119c473 README: add install dependencies for Arch Linux
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-12-10 22:33:27 +01:00
Krzysztof Kozlowski
fcada07889 meson: fix language typo
Fix language typo "of" -> "if".

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-12-10 22:33:09 +01:00
Dmitry Baryshkov
65d867355e Merge pull request #54 from krzk/space-clean
Clean trailing white-spaces
2023-12-03 21:43:11 +02:00
Krzysztof Kozlowski
581f14d8f6 Clean trailing white-spaces
Drop trailing white-spaces and tabs.  No functional changes.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-12-03 20:07:06 +01:00
Dmitry Baryshkov
2c465e56dd Merge pull request #53 from lumag/banner
cdba-server: add CDBA-server banner to be output on startup
2023-11-29 15:44:26 +02:00
Dmitry Baryshkov
d35abc800d cdba-server: add CDBA-server banner to be output on startup
Granted all possible issues with SSH, especially in the remote and/or
proxied labs, and possible issues with the board being present but
failing to power up, it is useful to have a banner message once CDBA was
started. This gives user a clear picture that the connection is fine and
the server is trying to power up the board.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-11-29 15:23:46 +02:00
Dmitry Baryshkov
5edc55cff8 Merge pull request #52 from lumag/syslog
Syslog sypport
2023-11-29 15:22:45 +02:00
Dmitry Baryshkov
43ed93357d cdba-server: add syslog support
Log messages to the syslog when the user opens a board.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-11-29 15:22:26 +02:00
Dmitry Baryshkov
b32d98f7a4 cdba-server: provide fallbacks for the username value
We use the CDBA_USER value as a way to pass info from cdba-shell to
cdba-server. However if it is not provide (e.g. because the cdba-server
is started directly by shell) add a fallback to the system's USER
variable. And if that's also not set, provide a safe default of
'nobody'.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-11-29 15:22:26 +02:00
Dmitry Baryshkov
3269b8b891 Merge pull request #51 from CodeLinaro/for-linux-msm/status-support
Programmatic access to remote power measurements
2023-11-28 05:34:11 +02:00
Bjorn Andersson
0ad34da4f2 samples: Provide sample with status-cmd
Provide a sample defining the status-cmd property.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:33:35 -06:00
Bjorn Andersson
6d8ff75e31 README: Introduce status messages and fifo
Introduce description of the status fifo, the status command, and the
data format for these in the README.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:58 -06:00
Bjorn Andersson
cc91b34f3a device: Disable USB on boot
Leaving USB connected might cause hickups on the USB bus, and causes
power measurements to report incorrect data. Turn it off once the image
has been downloaded.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:57 -06:00
Bjorn Andersson
81e46878ed cdba-server: Allow external status command
While the CDB Assist and QcomLT Debugboard is measuring voltage and
current on the DC jack directly in the backend, other backends and
further measurements can be performed using custom tooling.

Introduce support for invoking an external "status-cmd" to produce such
status updates.

The status command should on its stdout produce json-formatted status
updates following the same format as the cdba-server:

  {"ts":%d.%03d, "name": {["mv"|"ma"]: %u}(, "name2": {["mv"|"ma"]: %u})*}

with the ts aquired using clock_gettime(CLOCK_MONOTONIC) and provided in
seconds and milliseconds since the first measurement.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:57 -06:00
Bjorn Andersson
c8e29e3400 qcomlt_dbg: Enable power status reporting
The QcomLT DebugBoard has a voltage and current sensor on the 12V DC
line, which the firmware will measure upon request.

Add a periodic request for this information, parse out the responses and
report using the status helper functions.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:56 -06:00
Bjorn Andersson
130720a6df cdba: Introduce status pipe
The updated format and behavior of the status messages is not useful for
human consumption in the console stream, but rather for programatical
consumption by 3rd party tools.

Switch the status message stream to an optional fifo, which can be
consumed separately from the console - by humans or by tools.

The fifo is created and opened and status messages requested, if the
'-s <file>' option is specified.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:55 -06:00
Bjorn Andersson
0a3d51e9c8 cdba-server: Repurpose status update request
The MSG_STATUS_UPDATE message when sent from the client to the server,
has until now indicated a request for a single status update. This was
suitable when the update was for human consumption on occasional basis.

But with the transition to producing status messages for programatical
consumption it makes more sense to just keep the stream on, without the
client having to poll the server for updates. This can in particular
keep the external "status command" mechanism simpler.

Just enabling the stream of status updates would spam the console with
status updates for those users that hasn't updated their clients, so the
client needs to opt-in to the status stream.

Repurpose the status update message (sent from the client) to indicate
that the streaming of status updates should be enabled.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:54 -06:00
Bjorn Andersson
1cef583b11 cdba-server: Introduce helper for sending measurements
The current format of the cdb_assist backend status messages was never
intended to be parsed by a non-human, and the format doesn't extend well
to other backends.

Extend the format to be formatted as a json string, with a timestamp,
implemented in a separate status module.

The button status is skipped from the new status message, as it reflect
the output-values as set by cdba itself, rather than any measured state.

The timestamp is offset to the first measurement, to avoid disclosing
the uptime of the machine cdba-server is running on.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:18:23 -06:00
44 changed files with 1501 additions and 875 deletions

54
README
View File

@@ -5,6 +5,7 @@ attached using a CDB Assist [https://github.com/sonyxperiadev/CDB-Assist] or Con
= Dependencies = Dependencies
sudo apt-get install libudev-dev libyaml-dev libftdi1-dev pkg-config meson for debian systems sudo apt-get install libudev-dev libyaml-dev libftdi1-dev pkg-config meson for debian systems
dnf install systemd-devel libyaml-devel libftdi1-devel pkg-config meson for fedora systems dnf install systemd-devel libyaml-devel libftdi1-devel pkg-config meson for fedora systems
pacman -S libftdi libgpiod libyaml pkgconf meson for Arch systems
= Device side = Device side
On the host with the CDB Assist or Conmux attached the "cdba-server" executable is run On the host with the CDB Assist or Conmux attached the "cdba-server" executable is run
@@ -18,7 +19,7 @@ from sandbox/cdba/cdba-server. Available devices are read from $HOME/.cdba
= Client side = Client side
The client is invoked as: The client is invoked as:
cdba -b <board> -h <host> [-c <power-cylce-count>] boot.img cdba -b <board> -h <host> [-c <power-cylce-count>] [-s <status-fifo>] boot.img
<host> will be connected to using ssh and <board> will be selected for <host> will be connected to using ssh and <board> will be selected for
operation. As the board's fastboot interface shows up the given boot.img will operation. As the board's fastboot interface shows up the given boot.img will
@@ -31,9 +32,25 @@ If the optional -c is given, the board will upon receiving the tilde sequence
restart the board the given number of times. Each time booting the given restart the board the given number of times. Each time booting the given
boot.img. boot.img.
The optional -s argument can be used to specify that a fifo should be created
and opened. cdba will request the server to start sending status/measurement
updates, which will be written to this fifo.
How to quit the console and close session: ctrl+a then q
= Server side
== Device configuration == Device configuration
The list of attached devices is read from $HOME/.cdba and is YAML formatted. The list of attached devices is read from $HOME/.cdba and is YAML formatted.
== Status command
The "status-cmd" property for a board specifies a command line that should be
executed to perform measurements and report status updates to the client. The
command is expected to run for the duration of the board session and should
produce a continuous stream of json-formatted lines of status updates according
to the format defined in this document.
=== Example === Example
devices: devices:
- board: db2k - board: db2k
@@ -110,3 +127,38 @@ devices:
fastboot: cacafada fastboot: cacafada
fastboot_set_active: true fastboot_set_active: true
fastboot_key_timeout: 2 fastboot_key_timeout: 2
= Status messages
The status messages that are used by the client fifo and the server's status
command should be json-formatted, with one status update per line.
Each message should contain one timestamp member "ts", and one or more
measurement members. Like so:
{"ts":%d.%03d, "name": {["mv"|"ma"]: %u}(, "name2": {["mv"|"ma"]: %u})*}
The timestamp member ("ts"), should provide the time since first measurement in
decimal form with millisecond accuracy.
The key for the measurement members should be an identifier of the measured
resources, and the value should be an object with members for each unit
measured for the given resource and the measured value.
Valid units to report are "mv", "ma", and "mw".
Note that the cadence of measurement might differ between different items to be
measured, so not all status messages contains data for all items that can be
measured.
== Examples
Single resource "dc" measured at 20.271s, with voltage and current reported:
{"ts":20.271, "dc":{ "mv": 12165, "ma": 114}}
Multiple resources measured in a single status message, followed by single
resource measurement, all with voltage and current reported:
{"ts":38.341, "battery":{"mv":8023, "ma":725}, "vdd_cx":{"mv":750, "ma":466}}
{"ts":44.339, "battery":{"mv":8023, "ma":733}}

87
cdba-power.c Normal file
View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 2024, Linaro Ltd.
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "cdba-server.h"
#include "device.h"
#include "device_parser.h"
#include "watch.h"
void cdba_send_buf(int type, size_t len, const void *buf)
{
/* ignore console messages */
}
static void usage(const char *name)
{
fprintf(stderr, "Usage: %s <board> on|off\n", name);
exit(EXIT_FAILURE);
}
static struct device *selected_device;
bool ready(void)
{
return device_is_running(selected_device);
}
int main(int argc, char **argv)
{
const char *home;
const char *name;
bool on;
int ret;
if (argc != 3)
usage(argv[0]);
if (!strcmp(argv[2], "on"))
on = true;
else if (!strcmp(argv[2], "off"))
on = false;
else
usage(argv[0]);
home = getenv("HOME");
if (home)
chdir(home);
ret = device_parser(".cdba");
if (ret) {
ret = device_parser("/etc/cdba");
if (ret) {
fprintf(stderr, "device parser: unable to open config file\n");
exit(1);
}
}
name = argv[1];
selected_device = device_open(name, "nobody");
if (!selected_device) {
fprintf(stderr, "failed to open %s\n", name);
exit(EXIT_FAILURE);
}
if (on) {
device_power(selected_device, true);
watch_main_loop(ready);
selected_device->usb_always_on = true;
selected_device->power_always_on = true;
} else {
device_usb(selected_device, false);
device_power(selected_device, false);
}
device_close(selected_device);
return 0;
}

View File

@@ -2,34 +2,8 @@
* Copyright (c) 2016-2018, Linaro Ltd. * Copyright (c) 2016-2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/time.h>
#include <alloca.h>
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
@@ -38,6 +12,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <syslog.h>
#include "cdba-server.h" #include "cdba-server.h"
#include "circ_buf.h" #include "circ_buf.h"
@@ -45,40 +20,12 @@
#include "device_parser.h" #include "device_parser.h"
#include "fastboot.h" #include "fastboot.h"
#include "list.h" #include "list.h"
#include "watch.h"
static bool quit_invoked;
static const char *username; static const char *username;
struct device *selected_device; struct device *selected_device;
int tty_open(const char *tty, struct termios *old)
{
struct termios tios;
int ret;
int fd;
fd = open(tty, O_RDWR | O_NOCTTY | O_EXCL);
if (fd < 0)
err(1, "unable to open \"%s\"", tty);
ret = tcgetattr(fd, old);
if (ret < 0)
err(1, "unable to retrieve \"%s\" tios", tty);
memset(&tios, 0, sizeof(tios));
tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
tios.c_iflag = IGNPAR;
tios.c_oflag = 0;
tcflush(fd, TCIFLUSH);
ret = tcsetattr(fd, TCSANOW, &tios);
if (ret < 0)
err(1, "unable to update \"%s\" tios", tty);
return fd;
}
static void fastboot_opened(struct fastboot *fb, void *data) static void fastboot_opened(struct fastboot *fb, void *data)
{ {
const uint8_t one = 1; const uint8_t one = 1;
@@ -108,12 +55,14 @@ static struct fastboot_ops fastboot_ops = {
static void msg_select_board(const void *param) static void msg_select_board(const void *param)
{ {
selected_device = device_open(param, username, &fastboot_ops); selected_device = device_open(param, username);
if (!selected_device) { if (!selected_device) {
fprintf(stderr, "failed to open %s\n", (const char *)param); fprintf(stderr, "failed to open %s\n", (const char *)param);
quit_invoked = true; watch_quit();
} }
device_fastboot_open(selected_device, &fastboot_ops);
cdba_send(MSG_SELECT_BOARD); cdba_send(MSG_SELECT_BOARD);
} }
@@ -144,6 +93,12 @@ static void msg_fastboot_download(const void *data, size_t len)
} }
} }
static void msg_fastboot_continue(void)
{
device_fastboot_continue(selected_device);
cdba_send(MSG_FASTBOOT_CONTINUE);
}
void cdba_send_buf(int type, size_t len, const void *buf) void cdba_send_buf(int type, size_t len, const void *buf)
{ {
struct msg msg = { struct msg msg = {
@@ -210,7 +165,7 @@ static int handle_stdin(int fd, void *buf)
// fprintf(stderr, "fastboot boot\n"); // fprintf(stderr, "fastboot boot\n");
break; break;
case MSG_STATUS_UPDATE: case MSG_STATUS_UPDATE:
device_print_status(selected_device); device_status_enable(selected_device);
break; break;
case MSG_VBUS_ON: case MSG_VBUS_ON:
device_usb(selected_device, true); device_usb(selected_device, true);
@@ -227,6 +182,9 @@ static int handle_stdin(int fd, void *buf)
case MSG_BOARD_INFO: case MSG_BOARD_INFO:
device_info(username, msg->data, msg->len); device_info(username, msg->data, msg->len);
break; break;
case MSG_FASTBOOT_CONTINUE:
msg_fastboot_continue();
break;
default: default:
fprintf(stderr, "unk %d len %d\n", msg->type, msg->len); fprintf(stderr, "unk %d len %d\n", msg->type, msg->len);
exit(1); exit(1);
@@ -238,124 +196,27 @@ static int handle_stdin(int fd, void *buf)
return 0; return 0;
} }
struct watch {
struct list_head node;
int fd;
int (*cb)(int, void*);
void *data;
};
struct timer {
struct list_head node;
struct timeval tv;
void (*cb)(void *);
void *data;
};
static struct list_head read_watches = LIST_INIT(read_watches);
static struct list_head timer_watches = LIST_INIT(timer_watches);
void watch_add_readfd(int fd, int (*cb)(int, void*), void *data)
{
struct watch *w;
w = calloc(1, sizeof(*w));
w->fd = fd;
w->cb = cb;
w->data = data;
list_add(&read_watches, &w->node);
}
void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data)
{
struct timeval tv_timeout;
struct timeval now;
struct timer *t;
t = calloc(1, sizeof(*t));
gettimeofday(&now, NULL);
tv_timeout.tv_sec = timeout_ms / 1000;
tv_timeout.tv_usec = (timeout_ms % 1000) * 1000;
t->cb = cb;
t->data = data;
timeradd(&now, &tv_timeout, &t->tv);
list_add(&timer_watches, &t->node);
}
static struct timeval *watch_timer_next(void)
{
static struct timeval timeout;
struct timeval now;
struct timer *next;
struct timer *t;
if (list_empty(&timer_watches))
return NULL;
next = list_entry_first(&timer_watches, struct timer, node);
list_for_each_entry(t, &timer_watches, node) {
if (timercmp(&t->tv, &next->tv, <))
next = t;
}
gettimeofday(&now, NULL);
timersub(&next->tv, &now, &timeout);
if (timeout.tv_sec < 0) {
timeout.tv_sec = 0;
timeout.tv_usec = 0;
}
return &timeout;
}
static void watch_timer_invoke(void)
{
struct timeval now;
struct timer *tmp;
struct timer *t;
gettimeofday(&now, NULL);
list_for_each_entry_safe(t, tmp, &timer_watches, node) {
if (timercmp(&t->tv, &now, <)) {
t->cb(t->data);
list_del(&t->node);
free(t);
}
}
}
static void sigpipe_handler(int signo) static void sigpipe_handler(int signo)
{ {
quit_invoked = true; watch_quit();
}
void watch_quit(void)
{
quit_invoked = true;
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct timeval *timeoutp;
struct watch *w;
fd_set rfds;
int flags; int flags;
int nfds;
int ret; int ret;
signal(SIGPIPE, sigpipe_handler); signal(SIGPIPE, sigpipe_handler);
fprintf(stderr, "Starting cdba server\n");
username = getenv("CDBA_USER"); username = getenv("CDBA_USER");
if (!username)
username = getenv("USER");
if (!username)
username = "nobody";
openlog("cdba-server", 0, LOG_DAEMON);
ret = device_parser(".cdba"); ret = device_parser(".cdba");
if (ret) { if (ret) {
@@ -371,40 +232,7 @@ int main(int argc, char **argv)
flags = fcntl(STDIN_FILENO, F_GETFL, 0); flags = fcntl(STDIN_FILENO, F_GETFL, 0);
fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK); fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK);
while (!quit_invoked) { watch_run();
nfds = 0;
list_for_each_entry(w, &read_watches, node) {
nfds = MAX(nfds, w->fd);
FD_SET(w->fd, &rfds);
}
if (!FD_ISSET(STDIN_FILENO, &rfds)) {
fprintf(stderr, "rfds is trash!\n");
goto done;
}
timeoutp = watch_timer_next();
ret = select(nfds + 1, &rfds, NULL, NULL, timeoutp);
if (ret < 0 && errno == EINTR)
continue;
else if (ret < 0)
break;
watch_timer_invoke();
list_for_each_entry(w, &read_watches, node) {
if (FD_ISSET(w->fd, &rfds)) {
ret = w->cb(w->fd, w->data);
if (ret < 0) {
fprintf(stderr, "cb returned %d\n", ret);
goto done;
}
}
}
}
done:
/* if we got here, stdin/out/err might be not accessible anymore */ /* if we got here, stdin/out/err might be not accessible anymore */
ret = open("/dev/null", O_RDWR); ret = open("/dev/null", O_RDWR);

View File

@@ -6,14 +6,6 @@
#include "cdba.h" #include "cdba.h"
void watch_add_readfd(int fd, int (*cb)(int, void*), void *data);
int watch_add_quit(int (*cb)(int, void*), void *data);
void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data);
void watch_quit(void);
int watch_run(void);
int tty_open(const char *tty, struct termios *old);
void cdba_send_buf(int type, size_t len, const void *buf); void cdba_send_buf(int type, size_t len, const void *buf);
#define cdba_send(type) cdba_send_buf(type, 0, NULL) #define cdba_send(type) cdba_send_buf(type, 0, NULL)

111
cdba.c
View File

@@ -2,31 +2,7 @@
* Copyright (c) 2016-2018, Linaro Ltd. * Copyright (c) 2016-2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/select.h> #include <sys/select.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -51,6 +27,9 @@
static bool quit; static bool quit;
static bool fastboot_repeat; static bool fastboot_repeat;
static bool fastboot_done; static bool fastboot_done;
static bool fastboot_continue;
static int status_fd = -1;
static const char *fastboot_file; static const char *fastboot_file;
@@ -338,6 +317,22 @@ static void request_power_off(void)
list_add(&work_items, &work.node); list_add(&work_items, &work.node);
} }
static void request_fastboot_continue_fn(struct work *work, int ssh_stdin)
{
int ret;
ret = cdba_send(ssh_stdin, MSG_FASTBOOT_CONTINUE);
if (ret < 0)
err(1, "failed to send fastboot continue request");
}
static void request_fastboot_continue(void)
{
static struct work work = { request_fastboot_continue_fn };
list_add(&work_items, &work.node);
}
struct fastboot_download_work { struct fastboot_download_work {
struct work work; struct work work;
@@ -398,12 +393,40 @@ static void request_fastboot_files(void)
static void handle_status_update(const void *data, size_t len) static void handle_status_update(const void *data, size_t len)
{ {
char *str = alloca(len + 1); if (status_fd < 0)
return;
memcpy(str, data, len); write(status_fd, data, len);
str[len] = '\n'; }
write(STDOUT_FILENO, str, len + 1); static void status_enable_fn(struct work *work, int ssh_stdin)
{
cdba_send(ssh_stdin, MSG_STATUS_UPDATE);
free(work);
}
static void status_pipe_open(const char *path)
{
struct work *work;
int ret;
int fd;
ret = mkfifo(path, 0600);
if (ret < 0 && errno != EEXIST)
err(1, "failed to create fifo %s", path);
fd = open(path, O_RDWR | O_NONBLOCK);
if (fd < 0)
err(1, "failed to open fifo %s", path);
status_fd = fd;
/* Queue a MSG_STATUS_UPDATE request */
work = malloc(sizeof(*work));
work->fn = status_enable_fn;
list_add(&work_items, &work->node);
} }
static void handle_list_devices(const void *data, size_t len) static void handle_list_devices(const void *data, size_t len)
@@ -502,10 +525,14 @@ static int handle_message(struct circ_buf *buf)
case MSG_FASTBOOT_PRESENT: case MSG_FASTBOOT_PRESENT:
if (*(uint8_t*)msg->data) { if (*(uint8_t*)msg->data) {
// printf("======================================== MSG_FASTBOOT_PRESENT(on)\n"); // printf("======================================== MSG_FASTBOOT_PRESENT(on)\n");
if (!fastboot_done || fastboot_repeat) if (fastboot_continue) {
request_fastboot_continue();
fastboot_continue = false;
} else if (!fastboot_done || fastboot_repeat) {
request_fastboot_files(); request_fastboot_files();
else } else {
quit = true; quit = true;
}
} else { } else {
fastboot_done = true; fastboot_done = true;
// printf("======================================== MSG_FASTBOOT_PRESENT(off)\n"); // printf("======================================== MSG_FASTBOOT_PRESENT(off)\n");
@@ -527,6 +554,9 @@ static int handle_message(struct circ_buf *buf)
handle_board_info(msg->data, msg->len); handle_board_info(msg->data, msg->len);
return -1; return -1;
break; break;
case MSG_FASTBOOT_CONTINUE:
// printf("======================================== MSG_FASTBOOT_CONTINUE\n");
break;
default: default:
fprintf(stderr, "unk %d len %d\n", msg->type, msg->len); fprintf(stderr, "unk %d len %d\n", msg->type, msg->len);
return -1; return -1;
@@ -555,7 +585,7 @@ static void usage(void)
extern const char *__progname; extern const char *__progname;
fprintf(stderr, "usage: %s -b <board> -h <host> [-t <timeout>] " fprintf(stderr, "usage: %s -b <board> -h <host> [-t <timeout>] "
"[-T <inactivity-timeout>] boot.img\n", "[-T <inactivity-timeout>] <boot.img>\n",
__progname); __progname);
fprintf(stderr, "usage: %s -i -b <board> -h <host>\n", fprintf(stderr, "usage: %s -i -b <board> -h <host>\n",
__progname); __progname);
@@ -577,6 +607,7 @@ int main(int argc, char **argv)
struct timeval timeout_total_tv; struct timeval timeout_total_tv;
struct termios *orig_tios; struct termios *orig_tios;
const char *server_binary = "cdba-server"; const char *server_binary = "cdba-server";
const char *status_pipe = NULL;
int timeout_inactivity = 0; int timeout_inactivity = 0;
int timeout_total = 600; int timeout_total = 600;
struct work *next; struct work *next;
@@ -597,7 +628,7 @@ int main(int argc, char **argv)
int opt; int opt;
int ret; int ret;
while ((opt = getopt(argc, argv, "b:c:C:h:ilRt:S:T:")) != -1) { while ((opt = getopt(argc, argv, "b:c:C:h:ilRt:S:s:T:")) != -1) {
switch (opt) { switch (opt) {
case 'b': case 'b':
board = optarg; board = optarg;
@@ -623,6 +654,9 @@ int main(int argc, char **argv)
case 'S': case 'S':
server_binary = optarg; server_binary = optarg;
break; break;
case 's':
status_pipe = optarg;
break;
case 't': case 't':
timeout_total = atoi(optarg); timeout_total = atoi(optarg);
break; break;
@@ -639,13 +673,15 @@ int main(int argc, char **argv)
switch (verb) { switch (verb) {
case CDBA_BOOT: case CDBA_BOOT:
if (optind >= argc || !board) if (optind > argc || !board)
usage(); usage();
fastboot_file = argv[optind]; fastboot_file = argv[optind];
if (lstat(fastboot_file, &sb)) if (!fastboot_file)
fastboot_continue = true;
else if (lstat(fastboot_file, &sb))
err(1, "unable to read \"%s\"", fastboot_file); err(1, "unable to read \"%s\"", fastboot_file);
if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode)) else if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))
errx(1, "\"%s\" is not a regular file", fastboot_file); errx(1, "\"%s\" is not a regular file", fastboot_file);
request_select_board(board); request_select_board(board);
@@ -661,6 +697,9 @@ int main(int argc, char **argv)
break; break;
} }
if (status_pipe)
status_pipe_open(status_pipe);
ret = fork_ssh(host, server_binary, ssh_fds); ret = fork_ssh(host, server_binary, ssh_fds);
if (ret) if (ret)
err(1, "failed to connect to \"%s\"", host); err(1, "failed to connect to \"%s\"", host);

1
cdba.h
View File

@@ -30,6 +30,7 @@ enum {
MSG_SEND_BREAK, MSG_SEND_BREAK,
MSG_LIST_DEVICES, MSG_LIST_DEVICES,
MSG_BOARD_INFO, MSG_BOARD_INFO,
MSG_FASTBOOT_CONTINUE,
}; };
#endif #endif

View File

@@ -17,7 +17,7 @@ case $CC in
esac esac
pacman -Syu --noconfirm \ pacman -Syu --noconfirm \
libftdi-compat \ libftdi \
libyaml \ libyaml \
systemd-libs \ systemd-libs \
libgpiod \ libgpiod \

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2018, Linaro Ltd. * Copyright (c) 2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <errno.h> #include <errno.h>

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2018, Linaro Ltd. * Copyright (c) 2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __CIRC_BUF_H__ #ifndef __CIRC_BUF_H__
#define __CIRC_BUF_H__ #define __CIRC_BUF_H__

View File

@@ -0,0 +1,8 @@
---
devices:
- board: myboard
name: "My Board"
alpaca: /dev/ttyACM0
console: /dev/ttyUSB0
fastboot: cacafada
status-cmd: /usr/bin/sample-measure-app --sample-rate 100 /dev/measure0

View File

@@ -0,0 +1,13 @@
---
devices:
- board: myboard
name: "My Board"
description: |
My Awesome board
console: /dev/ttyABC0
fastboot: cacafada
fastboot_set_active: true
fastboot_key_timeout: 2
laurent:
server: laurent.lan
relay: 5

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2020, Linaro Ltd. * Copyright (c) 2020, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -37,6 +13,8 @@
#include "cdba-server.h" #include "cdba-server.h"
#include "device.h" #include "device.h"
#include "tty.h"
#include "watch.h"
struct console { struct console {
int console_fd; int console_fd;

106
device.c
View File

@@ -2,31 +2,7 @@
* Copyright (c) 2016-2018, Linaro Ltd. * Copyright (c) 2016-2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -39,12 +15,15 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <syslog.h>
#include "cdba-server.h" #include "cdba-server.h"
#include "device.h" #include "device.h"
#include "fastboot.h" #include "fastboot.h"
#include "list.h" #include "list.h"
#include "ppps.h" #include "ppps.h"
#include "status-cmd.h"
#include "watch.h"
#define ARRAY_SIZE(x) ((sizeof(x)/sizeof((x)[0]))) #define ARRAY_SIZE(x) ((sizeof(x)/sizeof((x)[0])))
@@ -115,9 +94,10 @@ static bool device_check_access(struct device *device,
return false; return false;
} }
static int device_power_off(struct device *device);
struct device *device_open(const char *board, struct device *device_open(const char *board,
const char *username, const char *username)
struct fastboot_ops *fastboot_ops)
{ {
struct device *device; struct device *device;
@@ -126,11 +106,17 @@ struct device *device_open(const char *board,
goto found; goto found;
} }
syslog(LOG_INFO, "user %s asked for non-existing board %s", username, board);
return NULL; return NULL;
found: found:
if (!device_check_access(device, username)) if (!device_check_access(device, username)) {
syslog(LOG_INFO, "user %s access denied to the board %s", username, board);
return NULL; return NULL;
}
syslog(LOG_INFO, "user %s opening board %s", username, board);
assert(device->console_ops); assert(device->console_ops);
assert(device->console_ops->open); assert(device->console_ops->open);
@@ -148,11 +134,21 @@ found:
if (!device->console) if (!device->console)
errx(1, "failed to open device console"); errx(1, "failed to open device console");
/*
* Power off before opening fastboot. Otherwise if the device is
* already in the fastboot state, CDBA will detect it, then power up
* procedure will restart the device causing fastboot to disappear and
* appear again. This will cause CDBA to exit, ending up with the
* unbreakable fastboot-reset-second_fastboot-quit cycle.
* */
if (device->power_always_on) {
device_power_off(device);
sleep(2);
}
if (device->usb_always_on) if (device->usb_always_on)
device_usb(device, true); device_usb(device, true);
device->fastboot = fastboot_open(device->serial, fastboot_ops, NULL);
return device; return device;
} }
@@ -231,6 +227,11 @@ static void device_tick(void *data)
} }
} }
bool device_is_running(struct device *device)
{
return device->state == DEVICE_STATE_RUNNING;
}
static int device_power_on(struct device *device) static int device_power_on(struct device *device)
{ {
if (!device || !device_has_control(device, power)) if (!device || !device_has_control(device, power))
@@ -260,10 +261,18 @@ int device_power(struct device *device, bool on)
return device_power_off(device); return device_power_off(device);
} }
void device_print_status(struct device *device) void device_status_enable(struct device *device)
{ {
if (device_has_control(device, print_status)) if (device->status_enabled)
device_control(device, print_status); return;
if (device_has_control(device, status_enable))
device_control(device, status_enable);
if (device->status_cmd)
status_cmd_open(device);
device->status_enabled = true;
} }
void device_usb(struct device *device, bool on) void device_usb(struct device *device, bool on)
@@ -282,13 +291,36 @@ int device_write(struct device *device, const void *buf, size_t len)
return device_console(device, write, buf, len); return device_console(device, write, buf, len);
} }
void device_fastboot_open(struct device *device,
struct fastboot_ops *fastboot_ops)
{
device->fastboot = fastboot_open(device->serial, fastboot_ops, NULL);
}
void device_fastboot_boot(struct device *device) void device_fastboot_boot(struct device *device)
{ {
if (!device->fastboot) {
fprintf(stderr, "fastboot not opened\n");
return;
}
fastboot_boot(device->fastboot); fastboot_boot(device->fastboot);
} }
void device_fastboot_continue(struct device *device)
{
if (!device->fastboot) {
fprintf(stderr, "fastboot not opened\n");
return;
}
fastboot_continue(device->fastboot);
}
void device_fastboot_flash_reboot(struct device *device) void device_fastboot_flash_reboot(struct device *device)
{ {
if (!device->fastboot) {
fprintf(stderr, "fastboot not opened\n");
return;
}
fastboot_flash(device->fastboot, "boot"); fastboot_flash(device->fastboot, "boot");
fastboot_reboot(device->fastboot); fastboot_reboot(device->fastboot);
} }
@@ -300,6 +332,11 @@ void device_boot(struct device *device, const void *data, size_t len)
fastboot_set_active(device->fastboot, device->set_active); fastboot_set_active(device->fastboot, device->set_active);
fastboot_download(device->fastboot, data, len); fastboot_download(device->fastboot, data, len);
device->boot(device); device->boot(device);
if (device->status_enabled && !device->usb_always_on) {
warnx("disabling USB, use ^A V to enable");
device_usb(device, false);
}
} }
void device_send_break(struct device *device) void device_send_break(struct device *device)
@@ -356,7 +393,8 @@ void device_close(struct device *dev)
{ {
if (!dev->usb_always_on) if (!dev->usb_always_on)
device_usb(dev, false); device_usb(dev, false);
device_power(dev, false); if (!dev->power_always_on)
device_power(dev, false);
if (device_has_control(dev, close)) if (device_has_control(dev, close))
device_control(dev, close); device_control(dev, close);

View File

@@ -17,7 +17,7 @@ struct control_ops {
int (*power)(struct device *dev, bool on); int (*power)(struct device *dev, bool on);
void (*usb)(struct device *dev, bool on); void (*usb)(struct device *dev, bool on);
void (*key)(struct device *device, int key, bool asserted); void (*key)(struct device *device, int key, bool asserted);
void (*print_status)(struct device *dev); void (*status_enable)(struct device *dev);
}; };
struct console_ops { struct console_ops {
@@ -41,11 +41,14 @@ struct device {
unsigned voltage; unsigned voltage;
bool tickle_mmc; bool tickle_mmc;
bool usb_always_on; bool usb_always_on;
bool power_always_on;
struct fastboot *fastboot; struct fastboot *fastboot;
unsigned int fastboot_key_timeout; unsigned int fastboot_key_timeout;
int state; int state;
bool has_power_key; bool has_power_key;
bool status_enabled;
void (*boot)(struct device *); void (*boot)(struct device *);
const struct control_ops *control_ops; const struct control_ops *control_ops;
@@ -56,6 +59,8 @@ struct device {
void *cdb; void *cdb;
void *console; void *console;
char *status_cmd;
struct list_head node; struct list_head node;
}; };
@@ -68,22 +73,25 @@ struct device_user {
void device_add(struct device *device); void device_add(struct device *device);
struct device *device_open(const char *board, struct device *device_open(const char *board,
const char *username, const char *username);
struct fastboot_ops *fastboot_ops);
void device_close(struct device *dev); void device_close(struct device *dev);
int device_power(struct device *device, bool on); int device_power(struct device *device, bool on);
void device_print_status(struct device *device); void device_status_enable(struct device *device);
void device_usb(struct device *device, bool on); void device_usb(struct device *device, bool on);
int device_write(struct device *device, const void *buf, size_t len); int device_write(struct device *device, const void *buf, size_t len);
void device_boot(struct device *device, const void *data, size_t len); void device_boot(struct device *device, const void *data, size_t len);
void device_fastboot_open(struct device *device,
struct fastboot_ops *fastboot_ops);
void device_fastboot_boot(struct device *device); void device_fastboot_boot(struct device *device);
void device_fastboot_flash_reboot(struct device *device); void device_fastboot_flash_reboot(struct device *device);
void device_send_break(struct device *device); void device_send_break(struct device *device);
void device_list_devices(const char *username); void device_list_devices(const char *username);
void device_info(const char *username, const void *data, size_t dlen); void device_info(const char *username, const void *data, size_t dlen);
void device_fastboot_continue(struct device *device);
bool device_is_running(struct device *device);
enum { enum {
DEVICE_KEY_FASTBOOT, DEVICE_KEY_FASTBOOT,
@@ -97,6 +105,7 @@ extern const struct control_ops ftdi_gpio_ops;
extern const struct control_ops local_gpio_ops; extern const struct control_ops local_gpio_ops;
extern const struct control_ops external_ops; extern const struct control_ops external_ops;
extern const struct control_ops qcomlt_dbg_ops; extern const struct control_ops qcomlt_dbg_ops;
extern const struct control_ops laurent_ops;
extern const struct console_ops conmux_console_ops; extern const struct console_ops conmux_console_ops;
extern const struct console_ops console_ops; extern const struct console_ops console_ops;

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2018, Linaro Ltd. * Copyright (c) 2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
@@ -139,6 +115,11 @@ static void parse_board(struct device_parser *dp)
if (dev->control_options) if (dev->control_options)
set_control_ops(dev, &ftdi_gpio_ops); set_control_ops(dev, &ftdi_gpio_ops);
continue; continue;
} else if (!strcmp(key, "laurent")) {
dev->control_options = laurent_ops.parse_options(dp);
if (dev->control_options)
set_control_ops(dev, &laurent_ops);
continue;
} }
device_parser_expect(dp, YAML_SCALAR_EVENT, value, TOKEN_LENGTH); device_parser_expect(dp, YAML_SCALAR_EVENT, value, TOKEN_LENGTH);
@@ -193,6 +174,10 @@ static void parse_board(struct device_parser *dp)
dev->ppps_path = strdup(value); dev->ppps_path = strdup(value);
} else if (!strcmp(key, "ppps3_path")) { } else if (!strcmp(key, "ppps3_path")) {
dev->ppps3_path = strdup(value); dev->ppps3_path = strdup(value);
} else if (!strcmp(key, "status-cmd")) {
dev->status_cmd = strdup(value);
} else if (!strcmp(key, "power_always_on")) {
dev->power_always_on = !strcmp(value, "true");
} else { } else {
fprintf(stderr, "device parser: unknown key \"%s\"\n", key); fprintf(stderr, "device parser: unknown key \"%s\"\n", key);
exit(1); exit(1);

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2018, Linaro Ltd. * Copyright (c) 2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
@@ -41,8 +17,8 @@
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "cdba-server.h"
#include "device.h" #include "device.h"
#include "tty.h"
struct alpaca { struct alpaca {
int alpaca_fd; int alpaca_fd;

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2016-2018, Linaro Ltd. * Copyright (c) 2016-2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h> #include <ctype.h>
@@ -41,8 +17,10 @@
#include <termios.h> #include <termios.h>
#include <unistd.h> #include <unistd.h>
#include "cdba-server.h"
#include "device.h" #include "device.h"
#include "status.h"
#include "tty.h"
#include "watch.h"
struct cdb_assist { struct cdb_assist {
char serial[9]; char serial[9];
@@ -99,7 +77,7 @@ static void cdb_parser_bool(struct cdb_assist *cdb, const char *key, bool set)
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
if (strcmp(key, sz_keys[i]) == 0) if (strcmp(key, sz_keys[i]) == 0)
break; break;
switch (i) { switch (i) {
case 0: case 0:
cdb->vbat = set; cdb->vbat = set;
@@ -125,7 +103,7 @@ static void cdb_parser_voltage(struct cdb_assist *cdb, unsigned set, unsigned ac
cdb->voltage_actual = actual; cdb->voltage_actual = actual;
cdb->voltage_set = set; cdb->voltage_set = set;
} }
static void cdb_parser_vref(struct cdb_assist *cdb, unsigned vref) static void cdb_parser_vref(struct cdb_assist *cdb, unsigned vref)
{ {
cdb->vref = vref; cdb->vref = vref;
@@ -223,7 +201,7 @@ static void cdb_parser_push(struct cdb_assist *cdb, char ch)
case STATE_key_of: case STATE_key_of:
if (ch == 'f') if (ch == 'f')
cdb_parser_bool(cdb, cdb->key, false); cdb_parser_bool(cdb, cdb->key, false);
cdb->state = STATE_; cdb->state = STATE_;
break; break;
case STATE_key_value: case STATE_key_value:
if (isdigit(ch)) { if (isdigit(ch)) {
@@ -338,23 +316,37 @@ static void cdb_gpio(struct cdb_assist *cdb, int gpio, bool on)
cdb_ctrl_write(cdb, &cmd[gpio][on], 1); cdb_ctrl_write(cdb, &cmd[gpio][on], 1);
} }
static void cdb_assist_print_status(struct device *dev) static void cdb_assist_print_status(void *data)
{
struct cdb_assist *cdb = data;
struct status_value vbat[] = {
{
.unit = STATUS_MV,
.value = cdb->voltage_set,
},
{
.unit = STATUS_MA,
.value = cdb->current_actual,
},
{}
};
struct status_value vref[] = {
{
.unit = STATUS_MV,
.value = cdb->vref,
},
{}
};
status_send_values("vbat", vbat);
status_send_values("vref", vref);
}
static void cdb_assist_status_enable(struct device *dev)
{ {
struct cdb_assist *cdb = dev->cdb; struct cdb_assist *cdb = dev->cdb;
char buf[128];
int n;
n = sprintf(buf, "%umV %umA%s%s%s%s%s ref: %umV", watch_timer_add(1000, cdb_assist_print_status, cdb);
cdb->voltage_set,
cdb->current_actual,
cdb->vbat ? " vbat" : "",
cdb->vbus ? " vbus" : "",
cdb->btn[0] ? " btn1" : "",
cdb->btn[1] ? " btn2" : "",
cdb->btn[2] ? " btn3" : "",
cdb->vref);
cdba_send_buf(MSG_STATUS_UPDATE, n, buf);
} }
static void cdb_set_voltage(struct cdb_assist *cdb, unsigned mV) static void cdb_set_voltage(struct cdb_assist *cdb, unsigned mV)
@@ -384,7 +376,7 @@ const struct control_ops cdb_assist_ops = {
.open = cdb_assist_open, .open = cdb_assist_open,
.close = cdb_assist_close, .close = cdb_assist_close,
.power = cdb_assist_power, .power = cdb_assist_power,
.print_status = cdb_assist_print_status, .status_enable = cdb_assist_status_enable,
.usb = cdb_assist_usb, .usb = cdb_assist_usb,
.key = cdb_assist_key, .key = cdb_assist_key,
}; };

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2018, Linaro Ltd. * Copyright (c) 2018, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
@@ -42,6 +18,7 @@
#include "cdba-server.h" #include "cdba-server.h"
#include "device.h" #include "device.h"
#include "watch.h"
extern int h_errno; extern int h_errno;

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2021-2023, Linaro Ltd. * Copyright (c) 2021-2023, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <sys/types.h> #include <sys/types.h>

View File

@@ -2,31 +2,7 @@
* Copyright (c) 2023, Linaro Ltd. * Copyright (c) 2023, Linaro Ltd.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * SPDX-License-Identifier: BSD-3-Clause
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include <sys/socket.h> #include <sys/socket.h>

Some files were not shown because too many files have changed in this diff Show More