summaryrefslogtreecommitdiff
path: root/utils/hwstub/lib
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-08-02 15:37:30 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2017-01-24 15:25:14 +0100
commita36694eb4a1905ec45593ceff2fc20d7eff7c8d8 (patch)
tree8f52469d15940a2df599e5f0f97e73d4fecc1e3f /utils/hwstub/lib
parent56340f4cd0a6ab318a52d2a62ded36aad2946e1d (diff)
downloadrockbox-a36694eb4a1905ec45593ceff2fc20d7eff7c8d8.tar.gz
rockbox-a36694eb4a1905ec45593ceff2fc20d7eff7c8d8.zip
hwstub: implement EXEC command over net
Apparently I completely forgot to implement it so using hwstub over net would just fail all EXEC commands :-s Change-Id: I0d0506cbbce9b86c9a4f19036dacc922d1e51338
Diffstat (limited to 'utils/hwstub/lib')
-rw-r--r--utils/hwstub/lib/hwstub_net.cpp49
1 files changed, 46 insertions, 3 deletions
diff --git a/utils/hwstub/lib/hwstub_net.cpp b/utils/hwstub/lib/hwstub_net.cpp
index 7b62abd004..ddafea6351 100644
--- a/utils/hwstub/lib/hwstub_net.cpp
+++ b/utils/hwstub/lib/hwstub_net.cpp
@@ -714,9 +714,25 @@ error handle::get_dev_log(void *buf, size_t& buf_sz)
714 714
715error handle::exec_dev(uint32_t addr, uint16_t flags) 715error handle::exec_dev(uint32_t addr, uint16_t flags)
716{ 716{
717 (void) addr; 717 std::shared_ptr<hwstub::context> hctx = get_device()->get_context();
718 (void) flags; 718 if(!hctx)
719 return error::DUMMY; 719 return error::NO_CONTEXT;
720
721 context *ctx = dynamic_cast<context*>(hctx.get());
722 ctx->debug() << "[net::handle] --> EXEC(" << m_handle_id << ",0x" << std::hex
723 << addr << ", 0x" << std::hex << flags << ")\n";
724 uint32_t args[HWSTUB_NET_ARGS] = {0};
725 args[0] = m_handle_id;
726 args[1] = addr;
727 args[2] = flags;
728 error err = ctx->send_cmd(HWSERVER_EXEC, args, nullptr, 0, nullptr, nullptr);
729 if(err != error::SUCCESS)
730 {
731 ctx->debug() << "[net::handle] <-- EXEC failed: " << error_string(err) << "\n";
732 return err;
733 }
734 ctx->debug() << "[net::handle] <-- EXEC\n";
735 return error::SUCCESS;
720} 736}
721 737
722error handle::status() const 738error handle::status() const
@@ -1200,6 +1216,33 @@ error server::handle_cmd(client_state *state, uint32_t cmd, uint32_t args[HWSTUB
1200 debug() << "[net::srv::cmd] <-- WRITE\n"; 1216 debug() << "[net::srv::cmd] <-- WRITE\n";
1201 return error::SUCCESS; 1217 return error::SUCCESS;
1202 } 1218 }
1219 /* HWSERVER_EXEC */
1220 else if(cmd == HWSERVER_EXEC)
1221 {
1222 uint32_t hid = args[0];
1223 uint32_t addr = args[1];
1224 uint32_t flags = args[2];
1225 debug() << "[net::srv::cmd] --> EXEC(" << hid << ",0x" << std::hex << addr << ","
1226 << "0x" << std::hex << flags << ")\n";
1227 /* check ID is valid */
1228 auto it = state->handle_map.find(hid);
1229 if(it == state->handle_map.end())
1230 {
1231 debug() << "[net::srv::cmd] unknown handle ID\n";
1232 debug() << "[net::srv::cmd] <-- EXEC (error)\n";
1233 return error::ERROR;
1234 }
1235 /* exec */
1236 error err = it->second->exec(addr, flags);
1237 if(err != error::SUCCESS)
1238 {
1239 debug() << "[net::srv::cmd] cannot write: " << error_string(err) << "\n";
1240 debug() << "[net::srv::cmd] <-- EXEC (error)\n";
1241 return err;
1242 }
1243 debug() << "[net::srv::cmd] <-- EXEC\n";
1244 return error::SUCCESS;
1245 }
1203 else 1246 else
1204 { 1247 {
1205 debug() << "[net::srv::cmd] <-> unknown cmd (0x" << std::hex << cmd << ")\n"; 1248 debug() << "[net::srv::cmd] <-> unknown cmd (0x" << std::hex << cmd << ")\n";