Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
lerwys committed Jun 22, 2017
2 parents 221888a + 596983e commit 80637f2
Show file tree
Hide file tree
Showing 123 changed files with 2,513 additions and 344 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

language: c
compiler:
- clang
- gcc

sudo: false
Expand All @@ -17,30 +16,31 @@ matrix:
include:
- compiler: gcc
env: GRADLE="installLibPcieDriver collectRpms" DEPLOY="yes"
- compiler: clang
env: GRADLE="installLibPcieDriver assemble"

addons:
apt:
packages:
- uuid-dev
sonarqube:
organization: lnls-dig
token:
secure: "AXQyy5C9NUv1aeIeVuLClBtLDkZsR4MDTFpIkzgrZX5fOVtVjyukeXfxk91GOtR76lGS5aX0WZLz+yMxsjFcGb49wigPSArZ91VE/UUPMZEIenjzObFdlz23a4GcfBtzTqzlChLNj3AaD80Jt9jUWXlLxTg+1p3FjWmmPS4Nu/VmtL9Nk5XdUwWNnptWWgmf0oL1n9ACRtpEhlBWd8HqzgxfGcT+WPo99TqFm/RZkngSMfgy9u4n1EBixxT7xVe0YVx1pke9hKCpHBMypLuARide/ZAcUf9OeuSgRlpa2+cY/Fn1P6MNfPGIaDbCZQ7PjN8CSJFjsGq+WpT3kNEw96+FHGU4z43eih1Cgo4q6XfezVkk5eLq7QQQVPGDN72VIj2oBAvXoWLxqpY5mA95Nw/rWWahsRScYap+gMHIDGpEwd54RvUMbZSgYTxLc74x6VCMW71JwB0UwUPt9UczVvUQirvPP7JtS4Th0WbFMAXPdOJE0l2F5/mBHbJyWPfD9PA5R/EYIpVkEG5kaZeYcBi0yqIXhW+yAlL6oiPNM28b0RNRkg8bsM0JZL7Vz/+b7+4rU4Ac4b47pCRWgnK6CpWL4C8FY9i0hzAyGq4SCoZPUEHY+Q8zMaGWnqcUePGsk/5bIAtu/Ot7OZcdF9HU3Pg0yeqDyXuyP4sG2q5Er3I="
branches:
- master
- devel
- sonarqube-integration
- sonarqube-gradle

before_install:
- git submodule update --init --recursive

# Build and check this project
script:
- ./ci_build.sh
- sonar-scanner
- ./ci_scanner.sh

cache:
ccache: true
directories:
- '$HOME/.sonar/cache'

Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ boards_INCLUDE_DIRS = -Icommon/include/boards/$(BOARD)
# Include directories
INCLUDE_DIRS = $(boards_INCLUDE_DIRS) \
-Icore/common/include \
-Icore/revision/include \
-Icore/sm_io/include \
-Icore/sm_io_table/include \
-Iforeign/libsdbfs/include \
Expand Down Expand Up @@ -252,8 +253,8 @@ dev_mngr_OBJS += $(dev_mngr_core_OBJS) $(debug_OBJS) \
$(ll_io_utils_OBJS) $(dev_io_core_utils_OBJS)

common_app_OBJS = $(dev_io_core_OBJS) $(ll_io_OBJS) \
$(sm_io_OBJS) $(msg_OBJS) $(board_OBJS) \
$(board_common_OBJS)
$(sm_io_OBJS) $(sm_io_table_OBJS) $(msg_OBJS) \
$(board_OBJS) $(board_common_OBJS)

apps_OBJS = $(foreach app_obj,$(APPS),$($(app_obj)_all_OBJS))

Expand All @@ -268,6 +269,7 @@ GIT_USER_EMAIL = $(shell git config --get user.email)

OBJS_all = $(ll_io_OBJS) \
$(sm_io_OBJS) \
$(sm_io_table_OBJS) \
$(msg_OBJS) \
$(dev_mngr_OBJS) \
$(common_app_OBJS) \
Expand Down
1 change: 1 addition & 0 deletions apps/halcsd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ model {
lib project: ':core:boards:afcv3', library: 'afcv3'
lib project: ':core:boards:afcv3_1', library: 'afcv3_1'
lib project: ':core:boards:ml605', library: 'ml605'
lib project: ':core:revision', library: 'revision'
lib project: ':core:sm_io_table', library: 'sm_io_table'
lib project: ':core:common', library: 'common'
lib project: ':core:dev_io', library: 'dev_io'
Expand Down
66 changes: 53 additions & 13 deletions apps/halcsd/src/halcsd/c/halcsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,8 @@ int main (int argc, char *argv[])
broker_endp, verbose, devio_log_filename);
ASSERT_ALLOC (devio, err_devio_alloc);

/* We don't need it anymore */
free (dev_entry);
dev_entry = NULL;

/* Print SDB devices */
/* Print SDB devices. FIXME. This must be called before zactor_new,
* as it access LLIO layer unsafely */
devio_print_info (devio);

/* Start DEVIO loop */
Expand All @@ -497,12 +494,6 @@ int main (int argc, char *argv[])
goto err_server;
}

/* TODO: Implement and Send SPAWN messages to spawn SMIOs */

/* Spawn associated DEVIOs */
free (broker_endp);
broker_endp = NULL;

/* Spawn platform SMIOSs */
err = _spawn_platform_smios (server, devio_type, fe_smio_id, devio_hints,
dev_id);
Expand All @@ -511,6 +502,54 @@ int main (int argc, char *argv[])
goto err_plat_devio;
}

/* FIXME. Currently we have an issue with some SMIOs
* initialization.
*
* If the SMIOs are somewhat dependant, we might need
* to reconfigure them again once they are all up and ready.
* That's because the default configuration of some of them
* (called in smio_config_defaults) might depend on another
* SMIO initialization.
*
* Even worse, in FPGAs, some SMIOs might need an stable clock
* to be able to configure themselves, but some projects
* employ a dynamic clock configured on-thr-fly by the SMIO.
* So, some SMIOs might not even be able to initialize before
* this other SMIO configure the FPGA clock.
*
* Using a more brute-force solution we used to do the following:
*
* 1) We reset the endpoint here (not done here as most of
* our endpoints need to recreate its SMCH instances to be
* able to communicate and we don't do that on reconfigure,
* only on create)
* 2) Tell the SMIOs to reconfigure themselves
*
* But this posed complications as we could reset the endpoint
* without re-creating the SMIOs. So, to simplify this we just
* destroy the DEVIO and recreate it.
*
* */

/* Wait until all SMIO configuration is executed */
while (true) {
char *message = zstr_recv (server);
if (message == NULL) {
DBE_DEBUG (DBG_DEV_IO | DBG_LVL_TRACE, "[halcsd] Interrupted while waiting for $SMIO_CFG_DONE\n");
goto smio_cfg_done_err;
}

if (streq (message, "$SMIO_CFG_DONE")) {
free (message);
break;
}
free (message);
}

/* Now that everything is ready spawn INIT SMIO so clients can
* be sure HALCS is ready to go */
devio_register_sm (server, 0xdc64e778, 0, 0);

/* Accept and print any message back from server */
while (true) {
char *message = zstr_recv (server);
Expand All @@ -524,6 +563,7 @@ int main (int argc, char *argv[])
}
}

smio_cfg_done_err:
err_plat_devio:
zactor_destroy (&server);
err_server:
Expand Down Expand Up @@ -616,8 +656,8 @@ static devio_err_e _spawn_platform_smios (void *pipe, devio_type_e devio_type,
uint32_t smio_inst_id, zhashx_t *hints, uint32_t dev_id)
{
assert (pipe);
UNUSED(hints);
UNUSED(dev_id);
UNUSED(hints);
UNUSED(dev_id);

devio_err_e err = DEVIO_SUCCESS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ PartOf=halcs@%i.target

[Service]
EnvironmentFile=/etc/sysconfig/halcs-board
ExecStartPre=/bin/mkdir -p /media/remote_logs
ExecStart=/usr/local/bin/halcsd -f /usr/local/etc/halcs/halcs.cfg -n be -t pcie -i %i -b ipc:///tmp/malamute -l /media/remote_logs
Environment=HALCS_LOG_DIR=/var/log/halcs
ExecStartPre=/bin/mkdir -p ${HALCS_LOG_DIR}
ExecStart=/usr/local/bin/halcsd -f /usr/local/etc/halcs/halcs.cfg -n be -t pcie -i %i -b ipc:///tmp/malamute -l ${HALCS_LOG_DIR}
WorkingDirectory=/usr/local/bin
TimeoutStopSec=2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ PartOf=halcs@%i.target

[Service]
EnvironmentFile=/etc/sysconfig/halcs-board
ExecStartPre=/bin/mkdir -p /media/remote_logs
ExecStart=/usr/local/bin/halcsd -f /usr/local/etc/halcs/halcs.cfg -n fe -t eth -i %i -b ipc:///tmp/malamute -l /media/remote_logs
Environment=HALCS_LOG_DIR=/var/log/halcs
ExecStartPre=/bin/mkdir -p ${HALCS_LOG_DIR}
ExecStart=/usr/local/bin/halcsd -f /usr/local/etc/halcs/halcs.cfg -n fe -t eth -i %i -b ipc:///tmp/malamute -l ${HALCS_LOG_DIR}
WorkingDirectory=/usr/local/bin
TimeoutStopSec=2

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

INPUT=$1

INSTANCE_IDX=$(echo ${INPUT} | sed 's|.*-||g')
BOARD_IDX=$(expr ${INSTANCE_IDX} / 2 + ${INSTANCE_IDX} % 2)
HALCS_IDX=$(expr 1 - ${INSTANCE_IDX} % 2)

# Output space-separated indexes
echo ${INSTANCE_IDX} ${BOARD_IDX} ${HALCS_IDX}
35 changes: 35 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.3"
classpath "org.ajoberstar:gradle-git:1.7.1"
}
}

allprojects {
apply plugin: 'c'
apply plugin: 'br.lnls.dig.gradle.assemblevarianttask'
apply plugin: 'br.lnls.dig.gradle.compilerflags'
apply plugin: br.lnls.dig.gradle.currentplatform.CurrentPlatformPlugin
apply plugin: 'br.lnls.dig.gradle.sanec'

/* We only want to apply the sonarqube plugin if we are running standalone (vs as a subproject) */
if (rootProject == project) {
apply plugin: 'org.sonarqube'
}

sonarqube {
properties {
property "sonar.projectKey", "br.com.lnls.dig.halcs"
property "sonar.projectName", "HALCS Hardware Abstraction Layer for Control Systems"
property "sonar.projectVersion", "v0.5"

property "sonar.links.homepage", "https://github.com/lnls-dig/halcs"
property "sonar.links.ci", "https://travis-ci.org/lnls-dig/halcs"
property "sonar.links.scm", "https://github.com/lnls-dig/halcs"
property "sonar.links.issue", "https://github.com/lnls-dig/halcs/issues"

property "sonar.branch", "devel"

property "sonar.cfamily.build-wrapper-output", "bw-output"
property "sonar.cfamily.gcov.reportsPath", "."
}
}

model {
buildTypes {
debug
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package br.lnls.dig.gradle.sedtask

interface Command {
void apply(StringBuffer buffer, CommandCursor commandPosition)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package br.lnls.dig.gradle.sedtask

class CommandCursor {
private ArrayList<Command> commands
private int commandIndex = 0

CommandCursor(ArrayList<Command> commands) {
this.commands = commands
}

void next() {
commandIndex += 1
}

void advance(int count) {
commandIndex += count
}

Command getCurrentCommand() {
return commands.get(commandIndex)
}

boolean finished() {
return commandIndex == commands.size()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package br.lnls.dig.gradle.sedtask

abstract class ConditionalCommand implements Command {
int commandCount = 0

public void apply(StringBuffer buffer, CommandCursor commandPosition) {
if (conditionResult(buffer) != true)
commandPosition.advance(commandCount)

commandPosition.next()
}

protected abstract boolean conditionResult(StringBuffer buffer)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package br.lnls.dig.gradle.sedtask

import java.util.regex.Pattern

class ReplaceCommand implements Command {
private Pattern pattern
private String replacement

ReplaceCommand(Pattern pattern, String replacement) {
this.pattern = pattern
this.replacement = replacement
}

void apply(StringBuffer buffer, CommandCursor commandPosition) {
String line = buffer.toString()
String updatedLine = pattern.matcher(line).replaceFirst(replacement)

buffer.delete(0, buffer.length())
buffer.append(updatedLine)

commandPosition.next()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package br.lnls.dig.gradle.sedtask

import java.util.regex.Pattern

class SedCommands {
private List<Command> commands

SedCommands(List<Command> commands) {
this.commands = commands
}

void when(Pattern pattern, Closure commandBlock) {
WhenCommand command = new WhenCommand(pattern)
int commandBlockStart = commands.size() + 1

commands.add(command)

commandBlock.resolveStrategy = Closure.DELEGATE_FIRST
commandBlock.delegate = this
commandBlock()

int commandBlockEnd = commands.size()
int commandBlockSize = commandBlockEnd - commandBlockStart

command.commandCount = commandBlockSize
}

void replace(Pattern pattern, String replacement) {
commands.add(new ReplaceCommand(pattern, replacement))
}
}
Loading

0 comments on commit 80637f2

Please sign in to comment.