Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f32b0441b0
|
|||
|
19314cf2bd
|
@@ -1,19 +0,0 @@
|
||||
#ifndef _INCLUDE__SIGNALS_SESSION__CLIENT_H_
|
||||
#define _INCLUDE__SIGNALS_SESSION__CLIENT_H_
|
||||
|
||||
#include <signals_session/signals_session.h>
|
||||
#include <base/rpc_client.h>
|
||||
|
||||
namespace Signals { struct Session_client; }
|
||||
|
||||
struct Signals::Session_client : Genode::Rpc_client<Session>
|
||||
{
|
||||
Session_client(Genode::Capability<Session> cap) : Genode::Rpc_client<Session>(cap) {
|
||||
}
|
||||
|
||||
Genode::Signal_context_capability get_sig_con() override {
|
||||
return call<Rpc_get_sig_con>();
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__SIGNALS_SESSION__CLIENT_H_ */
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef _INCLUDE__SIGNALS_SESSION__CONNECTION_H_
|
||||
#define _INCLUDE__SIGNALS_SESSION__CONNECTION_H_
|
||||
|
||||
#include <signals_session/client.h>
|
||||
#include <base/connection.h>
|
||||
|
||||
namespace Signals { struct Connection; }
|
||||
|
||||
struct Signals::Connection : Genode::Connection<Session>, Session_client {
|
||||
Connection(Genode::Env &env) : Genode::Connection<Signals::Session>(env, session(env.parent(), "ram_quota=6K, cap_quota=4")),
|
||||
Session_client(cap()) { }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__SIGNALS_SESSION__CONNECTION_H_ */
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef _INCLUDE__SIGNALS_SESSION__SIGNALS_SESSION_H
|
||||
#define _INCLUDE__SIGNALS_SESSION__SIGNALS_SESSION_H
|
||||
|
||||
#include <session/session.h>
|
||||
#include <base/rpc.h>
|
||||
|
||||
namespace Signals { struct Session; }
|
||||
|
||||
struct Signals::Session : Genode::Session {
|
||||
static const char *service_name() { return "Signals"; }
|
||||
|
||||
enum { CAP_QUOTA = 2 };
|
||||
|
||||
virtual Genode::Signal_context_capability get_sig_con() = 0;
|
||||
|
||||
GENODE_RPC(Rpc_get_sig_con, Genode::Signal_context_capability, get_sig_con);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_get_sig_con);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__SIGNALS_SESSION__SIGNALS_SESSION_H */
|
||||
121
include/swcr/services/cpu.h
Normal file
121
include/swcr/services/cpu.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#ifndef __swcr_services_cpu_h__
|
||||
#define __swcr_services_cpu_h__
|
||||
|
||||
#include <root/component.h>
|
||||
#include <cpu_session/connection.h>
|
||||
|
||||
#include <swcr/services/pd.h>
|
||||
|
||||
namespace SWCR
|
||||
{
|
||||
class Cpu_session_component;
|
||||
class Cpu_session_factory;
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
class SWCR::Cpu_session_component : public Genode::Rpc_object<Genode::Cpu_session>
|
||||
{
|
||||
private:
|
||||
Genode::Env &_env;
|
||||
Genode::Cpu_connection _real_cpu;
|
||||
SWCR::Pd_session_component &_psc;
|
||||
|
||||
public:
|
||||
Cpu_session_component(Genode::Env &env, Pd_session_component &psc) : _env(env),
|
||||
_real_cpu(_env),
|
||||
_psc(psc)
|
||||
{
|
||||
_env.ep().rpc_ep().manage(this);
|
||||
}
|
||||
|
||||
~Cpu_session_component()
|
||||
{
|
||||
_env.ep().rpc_ep().dissolve(this);
|
||||
}
|
||||
|
||||
Thread_capability create_thread(Capability<Pd_session> pd,
|
||||
Name const &name,
|
||||
Affinity::Location affinity,
|
||||
Weight weight,
|
||||
addr_t utcb = 0)
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
return _real_cpu.create_thread(_psc.parent_pd_cap(), name, affinity, weight, utcb);
|
||||
};
|
||||
|
||||
void kill_thread(Thread_capability thread)
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
_real_cpu.kill_thread(thread);
|
||||
};
|
||||
|
||||
void exception_sigh(Signal_context_capability sigh)
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
_real_cpu.exception_sigh(sigh);
|
||||
};
|
||||
|
||||
Affinity::Space affinity_space() const
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
return _real_cpu.affinity_space();
|
||||
};
|
||||
|
||||
Dataspace_capability trace_control()
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
return _real_cpu.trace_control();
|
||||
};
|
||||
|
||||
int ref_account(Cpu_session_capability cpu_session)
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
return _real_cpu.ref_account(cpu_session);
|
||||
};
|
||||
|
||||
int transfer_quota(Cpu_session_capability cpu_session, size_t amount)
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
return _real_cpu.transfer_quota(cpu_session, amount);
|
||||
};
|
||||
|
||||
Quota quota()
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
return _real_cpu.quota();
|
||||
};
|
||||
|
||||
Capability<Native_cpu> native_cpu()
|
||||
{
|
||||
Genode::log("CPU::\033[33m", __func__, "\033[0m");
|
||||
return _real_cpu.native_cpu();
|
||||
};
|
||||
};
|
||||
|
||||
class SWCR::Cpu_session_factory : public Genode::Local_service<Cpu_session_component>::Factory
|
||||
{
|
||||
private:
|
||||
Genode::Env &_env;
|
||||
Genode::Allocator &_alloc;
|
||||
|
||||
Pd_session_component &_psc;
|
||||
|
||||
public:
|
||||
Cpu_session_factory(Genode::Env &env, Genode::Allocator &alloc, Pd_session_component &psc) : _env(env), _alloc(alloc), _psc(psc) { }
|
||||
~Cpu_session_factory() { }
|
||||
|
||||
Cpu_session_component &create(Args const &, Genode::Affinity) override
|
||||
{
|
||||
return *new (_alloc) Cpu_session_component(_env, _psc);
|
||||
}
|
||||
|
||||
void upgrade(Cpu_session_component &, Args const &) override { }
|
||||
|
||||
void destroy(Cpu_session_component &session) override
|
||||
{
|
||||
Genode::destroy(_alloc, &session);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*__swcr_services_cpu_h__*/
|
||||
213
include/swcr/services/pd.h
Normal file
213
include/swcr/services/pd.h
Normal file
@@ -0,0 +1,213 @@
|
||||
#ifndef __swcr_services_pd_h__
|
||||
#define __swcr_services_pd_h__
|
||||
|
||||
#include <root/component.h>
|
||||
#include <pd_session/connection.h>
|
||||
|
||||
namespace SWCR
|
||||
{
|
||||
class Pd_session_component;
|
||||
class Pd_session_factory;
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
class SWCR::Pd_session_component : public Genode::Rpc_object<Genode::Pd_session>
|
||||
{
|
||||
private:
|
||||
Genode::Env &_env;
|
||||
Genode::Pd_connection _real_pd;
|
||||
|
||||
public:
|
||||
Pd_session_component(Genode::Env &env, const char *label) : _env(env), _real_pd(_env, label)
|
||||
{
|
||||
_env.ep().rpc_ep().manage(this);
|
||||
}
|
||||
~Pd_session_component()
|
||||
{
|
||||
_env.ep().rpc_ep().dissolve(this);
|
||||
}
|
||||
|
||||
Ram_dataspace_capability alloc(size_t size, Cache_attribute cached = CACHED)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.alloc(size, cached);
|
||||
};
|
||||
|
||||
void free(Ram_dataspace_capability ds)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.free(ds);
|
||||
};
|
||||
|
||||
size_t dataspace_size(Ram_dataspace_capability ds) const
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.dataspace_size(ds);
|
||||
};
|
||||
|
||||
void assign_parent(Capability<Parent> parent)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.assign_parent(parent);
|
||||
};
|
||||
|
||||
bool assign_pci(addr_t pci_config_memory_address, uint16_t bdf)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.assign_pci(pci_config_memory_address, bdf);
|
||||
};
|
||||
|
||||
void map(addr_t virt, addr_t size)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.map(virt, size);
|
||||
};
|
||||
|
||||
Signal_source_capability alloc_signal_source()
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.alloc_signal_source();
|
||||
};
|
||||
|
||||
void free_signal_source(Signal_source_capability cap)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.free_signal_source(cap);
|
||||
};
|
||||
|
||||
Capability<Signal_context> alloc_context(Signal_source_capability source, unsigned long imprint)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.alloc_context(source, imprint);
|
||||
};
|
||||
|
||||
void free_context(Capability<Signal_context> cap)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.free_context(cap);
|
||||
};
|
||||
|
||||
void submit(Capability<Signal_context> context, unsigned cnt = 1)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.submit(context, cnt);
|
||||
};
|
||||
|
||||
Native_capability alloc_rpc_cap(Native_capability ep)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.alloc_rpc_cap(ep);
|
||||
};
|
||||
|
||||
void free_rpc_cap(Native_capability cap)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.free_rpc_cap(cap);
|
||||
};
|
||||
|
||||
Capability<Region_map> address_space()
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.address_space();
|
||||
};
|
||||
|
||||
Capability<Region_map> stack_area()
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.stack_area();
|
||||
};
|
||||
|
||||
Capability<Region_map> linker_area()
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.linker_area();
|
||||
};
|
||||
|
||||
void ref_account(Capability<Pd_session> pd)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.ref_account(pd);
|
||||
};
|
||||
|
||||
void transfer_quota(Capability<Pd_session> to, Cap_quota amount)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.transfer_quota(to, amount);
|
||||
};
|
||||
|
||||
Cap_quota cap_quota() const
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.cap_quota();
|
||||
};
|
||||
|
||||
Cap_quota used_caps() const
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.used_caps();
|
||||
};
|
||||
|
||||
void transfer_quota(Capability<Pd_session> to, Ram_quota amount)
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
_real_pd.transfer_quota(to, amount);
|
||||
};
|
||||
|
||||
Ram_quota ram_quota() const
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.ram_quota();
|
||||
};
|
||||
|
||||
Ram_quota used_ram() const
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.used_ram();
|
||||
};
|
||||
|
||||
Capability<Native_pd> native_pd()
|
||||
{
|
||||
Genode::log("PD::\033[33m", __func__, "\033[0m");
|
||||
return _real_pd.native_pd();
|
||||
};
|
||||
|
||||
Pd_session_capability parent_pd_cap()
|
||||
{
|
||||
return _real_pd.cap();
|
||||
}
|
||||
};
|
||||
|
||||
class SWCR::Pd_session_factory : public Genode::Local_service<Pd_session_component>::Factory
|
||||
{
|
||||
private:
|
||||
Genode::Env &_env;
|
||||
Genode::Allocator &_alloc;
|
||||
const char *_label;
|
||||
|
||||
Pd_session_component *_cpsc;
|
||||
|
||||
public:
|
||||
Pd_session_factory(Genode::Env &env, Genode::Allocator &alloc, const char *label) : _env(env), _alloc(alloc), _label(label) { }
|
||||
~Pd_session_factory() { }
|
||||
|
||||
Pd_session_component &create(Args const &, Genode::Affinity) override
|
||||
{
|
||||
_cpsc = new (_alloc) Pd_session_component(_env, _label);
|
||||
return *_cpsc;
|
||||
}
|
||||
|
||||
void upgrade(Pd_session_component &, Args const &) override { }
|
||||
|
||||
void destroy(Pd_session_component &session) override
|
||||
{
|
||||
Genode::destroy(_alloc, &session);
|
||||
}
|
||||
|
||||
Pd_session_component &custom_pd_session_component()
|
||||
{
|
||||
return *_cpsc;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*__swcr_services_pd_h__*/
|
||||
95
include/swcr/target_child.h
Normal file
95
include/swcr/target_child.h
Normal file
@@ -0,0 +1,95 @@
|
||||
#ifndef __swcr_target_child_h__
|
||||
#define __swcr_target_child_h__
|
||||
|
||||
#include <base/child.h>
|
||||
#include <swcr/services/pd.h>
|
||||
#include <swcr/services/cpu.h>
|
||||
|
||||
namespace SWCR
|
||||
{
|
||||
class Target_child;
|
||||
typedef Genode::Registered<Genode::Parent_service> Parent_service;
|
||||
typedef Genode::Registry<Parent_service> Parent_services;
|
||||
}
|
||||
|
||||
class SWCR::Target_child : public Genode::Child_policy
|
||||
{
|
||||
private:
|
||||
Genode::Env &_env;
|
||||
Genode::Heap _heap;
|
||||
Genode::Cap_quota const _cap_quota { 50 };
|
||||
Genode::Ram_quota const _ram_quota { 8 * 1024 * 1024 };
|
||||
|
||||
Parent_services &_parent_services;
|
||||
|
||||
SWCR::Pd_session_factory _psf;
|
||||
Genode::Local_service<Pd_session_component> _pls;
|
||||
|
||||
SWCR::Cpu_session_factory *_csf;
|
||||
Genode::Local_service<Cpu_session_component> *_cls;
|
||||
|
||||
Genode::Child _child;
|
||||
|
||||
template <typename T>
|
||||
static Genode::Service *_find_service(Genode::Registry<T> &services, Genode::Service::Name const &name)
|
||||
{
|
||||
Genode::Service *service = nullptr;
|
||||
services.for_each([&] (T &s) {
|
||||
if (!service && (s.name() == name))
|
||||
service = &s;
|
||||
});
|
||||
return service;
|
||||
}
|
||||
|
||||
Genode::Child_policy::Route
|
||||
resolve_session_request(Genode::Service::Name const &service_name,
|
||||
Genode::Session_label const &label) override
|
||||
{
|
||||
Genode::log(__func__, ": ", service_name, " ", label);
|
||||
auto route = [&] (Genode::Service &service) {
|
||||
return Genode::Child_policy::Route { .service = service,
|
||||
.label = label,
|
||||
.diag = Genode::Session::Diag() }; };
|
||||
|
||||
Genode::Service *service = nullptr;
|
||||
if (!Genode::strcmp("PD", service_name.string()))
|
||||
service = &_pls;
|
||||
else if (!Genode::strcmp("CPU", service_name.string()))
|
||||
service = _cls;
|
||||
else
|
||||
service = _find_service(_parent_services, service_name);
|
||||
return route(*service);
|
||||
}
|
||||
|
||||
public:
|
||||
Target_child(Genode::Env &env,
|
||||
Parent_services &parent_services) : _env(env),
|
||||
_heap(_env.ram(), _env.rm()),
|
||||
_parent_services(parent_services),
|
||||
_psf(_env, _heap, "hello"),
|
||||
_pls(_psf),
|
||||
_child(_env.rm(), _env.ep().rpc_ep(), *this)
|
||||
{ }
|
||||
~Target_child() { };
|
||||
|
||||
Name name() const override { return "hello"; };
|
||||
|
||||
Genode::Pd_session &ref_pd() override { return _env.pd(); }
|
||||
Genode::Pd_session_capability ref_pd_cap() const override { return _env.pd_session_cap(); }
|
||||
|
||||
void init(Genode::Pd_session &custom_pd, Genode::Pd_session_capability pd_cap) override
|
||||
{
|
||||
custom_pd.ref_account(ref_pd_cap());
|
||||
Genode::log("transfering");
|
||||
Pd_session_component &pdsc = _psf.custom_pd_session_component();
|
||||
_csf = new (_heap) SWCR::Cpu_session_factory(_env, _heap, pdsc);
|
||||
_cls = new (_heap) Genode::Local_service<SWCR::Cpu_session_component>(*_csf);
|
||||
ref_pd().transfer_quota(pdsc.parent_pd_cap(), _cap_quota);
|
||||
ref_pd().transfer_quota(pdsc.parent_pd_cap(), _ram_quota);
|
||||
Genode::log("done");
|
||||
/*ref_pd().transfer_quota(_cpsc.parent_pd_cap(), _cap_quota);
|
||||
ref_pd().transfer_quota(_cpsc.parent_pd_cap(), _ram_quota);*/
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*__swcr_target_child_h__*/
|
||||
@@ -1,84 +0,0 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
if {[expr [have_spec linux]] ||
|
||||
[expr [have_spec imx53] && [have_spec trustzone]] ||
|
||||
[have_spec rpi3] ||
|
||||
[expr [have_spec riscv]]} {
|
||||
puts "\n Run script is not supported on this platform. \n"; exit 0 }
|
||||
|
||||
create_boot_directory
|
||||
|
||||
import_from_depot [depot_user]/src/[base_src] \
|
||||
[depot_user]/pkg/[drivers_nic_pkg] \
|
||||
[depot_user]/src/init \
|
||||
[depot_user]/src/libc \
|
||||
[depot_user]/src/vfs_lwip \
|
||||
[depot_user]/src/vfs
|
||||
|
||||
build { app/eth_udp }
|
||||
|
||||
install_config {
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="drivers" caps="1000">
|
||||
<resource name="RAM" quantum="32M" constrain_phys="yes"/>
|
||||
<binary name="init"/>
|
||||
<route>
|
||||
<service name="ROM" label="config"> <parent label="drivers.config"/> </service>
|
||||
<service name="Timer"> <child name="timer"/> </service>
|
||||
<any-service> <parent/> </any-service>
|
||||
</route>
|
||||
<provides> <service name="Nic"/> </provides>
|
||||
</start>
|
||||
|
||||
<start name="eth_udp" caps="120">
|
||||
<resource name="RAM" quantum="4M"/>
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="dev"> <log/> </dir>
|
||||
<dir name="socket"> <lwip dhcp="yes"/> </dir>
|
||||
</vfs>
|
||||
<libc stdout="/dev/log" stderr="/dev/log" socket="/socket"/>
|
||||
</config>
|
||||
</start>
|
||||
</config>
|
||||
}
|
||||
|
||||
build_boot_image { eth_udp }
|
||||
|
||||
#
|
||||
# Qemu config
|
||||
#
|
||||
proc qemu_nic_model {} {
|
||||
if [have_spec x86] { return e1000 }
|
||||
if [have_spec lan9118] { return lan9118 }
|
||||
if [have_spec zynq] { return cadence_gem }
|
||||
return nic_model_missing
|
||||
}
|
||||
append qemu_args " -nographic "
|
||||
append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 "
|
||||
|
||||
run_genode_until forever
|
||||
|
||||
# vi: set ft=tcl :
|
||||
@@ -1,46 +0,0 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
build { core init timer signals }
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
install_config {
|
||||
<config>
|
||||
<parent-provides>
|
||||
<service name="LOG"/>
|
||||
<service name="PD"/>
|
||||
<service name="CPU"/>
|
||||
<service name="ROM"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="100"/>
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
<start name="signals_server">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Signals"/> </provides>
|
||||
</start>
|
||||
<start name="signals_client">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
</start>
|
||||
</config>}
|
||||
|
||||
#
|
||||
# Boot image
|
||||
#
|
||||
|
||||
build_boot_image { core ld.lib.so init timer signals_client signals_server }
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
run_genode_until forever
|
||||
96
run/swcr.run
Normal file
96
run/swcr.run
Normal file
@@ -0,0 +1,96 @@
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
set use_usb_driver [expr [have_spec omap4] || [have_spec arndale] || [have_spec rpi]]
|
||||
set use_nic_driver [expr !$use_usb_driver && ![have_spec odroid_xu] && ![have_spec linux]]
|
||||
|
||||
if {[expr !$use_usb_driver && !$use_nic_driver] ||
|
||||
[expr [have_spec imx53] && [have_spec trustzone]]} {
|
||||
puts "\n Run script is not supported on this platform. \n"; exit 0 }
|
||||
|
||||
set build_components {
|
||||
core init
|
||||
drivers/timer drivers/nic
|
||||
app/swcr app/hello
|
||||
}
|
||||
|
||||
lappend_if $use_usb_driver build_components drivers/usb
|
||||
lappend_if [have_spec gpio] build_components drivers/gpio
|
||||
|
||||
proc gpio_drv { } { if {[have_spec rpi] && [have_spec hw]} { return hw_gpio_drv }
|
||||
if {[have_spec rpi] && [have_spec foc]} { return foc_gpio_drv }
|
||||
return gpio_drv }
|
||||
|
||||
source ${genode_dir}/repos/base/run/platform_drv.inc
|
||||
append_platform_drv_build_components
|
||||
|
||||
build $build_components
|
||||
|
||||
create_boot_directory
|
||||
|
||||
#
|
||||
# Generate config
|
||||
#
|
||||
|
||||
set config {
|
||||
<config verbose="yes">
|
||||
<parent-provides>
|
||||
<service name="ROM"/>
|
||||
<service name="IRQ"/>
|
||||
<service name="IO_MEM"/>
|
||||
<service name="IO_PORT"/>
|
||||
<service name="PD"/>
|
||||
<service name="RM"/>
|
||||
<service name="CPU"/>
|
||||
<service name="LOG"/>
|
||||
</parent-provides>
|
||||
<default-route>
|
||||
<any-service> <parent/> <any-child/> </any-service>
|
||||
</default-route>
|
||||
<default caps="200"/>
|
||||
<start name="timer">
|
||||
<resource name="RAM" quantum="1M"/>
|
||||
<provides> <service name="Timer"/> </provides>
|
||||
</start>
|
||||
<start name="swcr" caps="300">
|
||||
<resource name="RAM" quantum="16M"/>
|
||||
</start>}
|
||||
|
||||
append_if [have_spec gpio] config "
|
||||
<start name=\"[gpio_drv]\" caps=\"140\">
|
||||
<resource name=\"RAM\" quantum=\"4M\"/>
|
||||
<provides><service name=\"Gpio\"/></provides>
|
||||
<config/>
|
||||
</start>"
|
||||
|
||||
append_if $use_usb_driver config {
|
||||
<start name="usb_drv" caps="120">
|
||||
<resource name="RAM" quantum="14M"/>
|
||||
<provides>
|
||||
<service name="Nic"/>
|
||||
</provides>
|
||||
<config ehci="yes">
|
||||
<nic mac="02:00:00:00:01:01" />
|
||||
</config>
|
||||
</start>}
|
||||
|
||||
append_platform_drv_config
|
||||
|
||||
append config {
|
||||
</config>
|
||||
}
|
||||
|
||||
install_config $config
|
||||
|
||||
#
|
||||
# Boot image
|
||||
#
|
||||
|
||||
build_boot_image { core ld.lib.so init swcr timer hello }
|
||||
|
||||
append qemu_args " -nographic "
|
||||
|
||||
#append_if [have_spec lan9119] qemu_args " -net nic,macaddr=02:00:00:00:01:03 -net nic,model=lan9118 -net tap,ifname=tap0,script=no "
|
||||
|
||||
run_genode_until forever
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* \brief Test client for the Hello RPC interface
|
||||
* \author Björn Döbel
|
||||
* \author Norman Feske
|
||||
* \date 2008-03-20
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <libc/component.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
void Libc::Component::construct(Libc::Env &env)
|
||||
{
|
||||
Libc::with_libc([&] () {
|
||||
struct sockaddr_in srv_addr;
|
||||
srv_addr.sin_port = htons(8080);
|
||||
srv_addr.sin_family = AF_INET;
|
||||
srv_addr.sin_addr.s_addr = inet_addr("192.168.100.0");
|
||||
|
||||
unsigned int len = sizeof(srv_addr);
|
||||
|
||||
int sd = ::socket(AF_INET, SOCK_DGRAM, 0);
|
||||
sendto(sd, "Hello World\n", 12, 0, (struct sockaddr*)&srv_addr, len);
|
||||
|
||||
char buf[64] = {'\0'};
|
||||
int ret = -1;
|
||||
while(true) {
|
||||
ret = recvfrom(sd, buf, sizeof(buf), 0, NULL, NULL);
|
||||
buf[ret] = '\0';
|
||||
Genode::log((const char *)buf);
|
||||
}
|
||||
|
||||
Genode::log("Connection closed…");
|
||||
|
||||
// ----------------------------------
|
||||
|
||||
});
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
TARGET = eth_udp
|
||||
SRC_CC = main.cc
|
||||
LIBS = base libc
|
||||
|
||||
CC_CXX_WARN_STRICT =
|
||||
32
src/app/swcr/main.cc
Normal file
32
src/app/swcr/main.cc
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <base/component.h>
|
||||
#include <swcr/target_child.h>
|
||||
|
||||
namespace SWCR
|
||||
{
|
||||
struct Main;
|
||||
}
|
||||
|
||||
struct SWCR::Main
|
||||
{
|
||||
Genode::Env &_env;
|
||||
Genode::Heap _heap { _env.ram(), _env.rm() };
|
||||
|
||||
Parent_services _parent_services { };
|
||||
|
||||
Main(Genode::Env &env) : _env(env)
|
||||
{
|
||||
const char *names[] = { "RM", "PD", "CPU", "IO_MEM", "IO_PORT", "IRQ", "ROM", "LOG", 0 };
|
||||
|
||||
for (unsigned i = 0; names[i]; i++)
|
||||
{
|
||||
new (_heap) Parent_service(_parent_services, env, names[i]);
|
||||
}
|
||||
|
||||
new (_heap) Target_child(_env, _parent_services);
|
||||
}
|
||||
};
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
static SWCR::Main main(env);
|
||||
}
|
||||
3
src/app/swcr/target.mk
Normal file
3
src/app/swcr/target.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
TARGET = swcr
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
||||
@@ -1,19 +0,0 @@
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <signals_session/connection.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
Signals::Connection _signals(env);
|
||||
Genode::Signal_transmitter _signal_transmitter(_signals.get_sig_con());
|
||||
|
||||
Timer::Connection _timer(env);
|
||||
|
||||
while(true) {
|
||||
_timer.msleep(1000);
|
||||
Genode::log("Sending signal…");
|
||||
_signal_transmitter.submit();
|
||||
};
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
TARGET = signals_client
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
||||
@@ -1,54 +0,0 @@
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <base/heap.h>
|
||||
#include <root/component.h>
|
||||
#include <signals_session/signals_session.h>
|
||||
|
||||
namespace Signals {
|
||||
struct Session_component;
|
||||
class Root_component;
|
||||
struct Main;
|
||||
}
|
||||
|
||||
struct Signals::Session_component : Genode::Rpc_object<Session> {
|
||||
Genode::Signal_context_capability _sig_con;
|
||||
Genode::Signal_context_capability get_sig_con() override {
|
||||
return _sig_con;
|
||||
}
|
||||
|
||||
Session_component(Genode::Signal_context_capability &sig_con) : _sig_con(sig_con) { }
|
||||
};
|
||||
|
||||
class Signals::Root_component : public Genode::Root_component<Session_component> {
|
||||
private:
|
||||
Genode::Signal_context_capability _sig_con;
|
||||
protected:
|
||||
Session_component *_create_session(const char *) override {
|
||||
return new (md_alloc()) Session_component(_sig_con);
|
||||
}
|
||||
|
||||
public:
|
||||
Root_component(Genode::Entrypoint &ep, Genode::Allocator &alloc, Genode::Signal_context_capability sig_con) : Genode::Root_component<Session_component>(ep, alloc), _sig_con(sig_con) { }
|
||||
};
|
||||
|
||||
struct Signals::Main {
|
||||
Genode::Env &_env;
|
||||
|
||||
Genode::Signal_handler<Main> _sig_handler = { _env.ep(), *this, &Main::_handle_signal };
|
||||
|
||||
Genode::Sliced_heap sliced_heap { _env.ram(), _env.rm() };
|
||||
|
||||
Signals::Root_component root { _env.ep(), sliced_heap, _sig_handler };
|
||||
|
||||
Main(Genode::Env &env) : _env(env) {
|
||||
env.parent().announce(env.ep().manage(root));
|
||||
}
|
||||
|
||||
void _handle_signal() {
|
||||
Genode::log("Signal received!");
|
||||
}
|
||||
};
|
||||
|
||||
void Component::construct(Genode::Env &env) {
|
||||
static Signals::Main main(env);
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
TARGET = signals_server
|
||||
SRC_CC = main.cc
|
||||
LIBS = base
|
||||
Reference in New Issue
Block a user