Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates: add module template. #53

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ header_dir = 'uhal'

subdir('include')
subdir('util')
subdir('templates')
subdir('modules')
subdir('app')
17 changes: 17 additions & 0 deletions templates/add_module.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -eu

module=$1
reporoot="$(git rev-parse --show-toplevel)"

upper_case() {
echo "$1" | tr '[:lower:]' '[:upper:]'
}

isubstitution=s,mod_template\\.h,modules/$module.h,
substitution=s/mod_template/$module/g
Substitution=s/$(upper_case mod_template)/$(upper_case $module)/g

sed -e $isubstitution -e $substitution -e $Substitution $reporoot/templates/mod_template.cc > $reporoot/modules/$module.cc
sed -e $substitution -e $Substitution $reporoot/templates/mod_template.h > $reporoot/include/modules/$module.h
9 changes: 9 additions & 0 deletions templates/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
templates_src = [
'mod_template.cc',
]
templates_lib = static_library(
'templates',
templates_src,
dependencies: [utilities],
install: false
)
41 changes: 41 additions & 0 deletions templates/mod_template.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "printer.h"
#include "util.h"
#include "mod_template.h"

namespace mod_template {

struct mod_template {
};

namespace {
constexpr unsigned MOD_TEMPLATE_DEVID = 0xdeadbeef;
struct sdb_device_info ref_devinfo = {
.vendor_id = LNLS_VENDORID,
.device_id = MOD_TEMPLATE_DEVID,
.abi_ver_major = 0
};
}

Core::Core(struct pcie_bars &bars):
RegisterDecoder(bars, ref_devinfo, {
}),
CONSTRUCTOR_REGS(struct mod_template)
{
set_read_dest(regs);
}
Core::~Core() = default;

void Core::decode()
{
}

Controller::Controller(struct pcie_bars &bars):
RegisterDecoderController(bars, ref_devinfo, &dec),
CONSTRUCTOR_REGS(struct mod_template),
dec(bars)
{
set_read_dest(regs);
}
Controller::~Controller() = default;

} /* namespace mod_template */
37 changes: 37 additions & 0 deletions templates/mod_template.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef MOD_TEMPLATE_H
#define MOD_TEMPLATE_H

#include <memory>

#include "controllers.h"
#include "decoders.h"

namespace mod_template {

struct mod_template;

class Core: public RegisterDecoder {
std::unique_ptr<struct mod_template> regs_storage;
struct mod_template &regs;

void decode() override;

public:
Core(struct pcie_bars &);
~Core() override;
};

class Controller: public RegisterDecoderController {
std::unique_ptr<struct mod_template> regs_storage;
struct mod_template &regs;

Core dec;

public:
Controller(struct pcie_bars &);
~Controller();
};

} /* namespace mod_template */

#endif