forked from len0rd/rockbox
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
This commit is contained in:
parent
56340f4cd0
commit
a36694eb4a
3 changed files with 90 additions and 12 deletions
|
@ -714,9 +714,25 @@ error handle::get_dev_log(void *buf, size_t& buf_sz)
|
|||
|
||||
error handle::exec_dev(uint32_t addr, uint16_t flags)
|
||||
{
|
||||
(void) addr;
|
||||
(void) flags;
|
||||
return error::DUMMY;
|
||||
std::shared_ptr<hwstub::context> hctx = get_device()->get_context();
|
||||
if(!hctx)
|
||||
return error::NO_CONTEXT;
|
||||
|
||||
context *ctx = dynamic_cast<context*>(hctx.get());
|
||||
ctx->debug() << "[net::handle] --> EXEC(" << m_handle_id << ",0x" << std::hex
|
||||
<< addr << ", 0x" << std::hex << flags << ")\n";
|
||||
uint32_t args[HWSTUB_NET_ARGS] = {0};
|
||||
args[0] = m_handle_id;
|
||||
args[1] = addr;
|
||||
args[2] = flags;
|
||||
error err = ctx->send_cmd(HWSERVER_EXEC, args, nullptr, 0, nullptr, nullptr);
|
||||
if(err != error::SUCCESS)
|
||||
{
|
||||
ctx->debug() << "[net::handle] <-- EXEC failed: " << error_string(err) << "\n";
|
||||
return err;
|
||||
}
|
||||
ctx->debug() << "[net::handle] <-- EXEC\n";
|
||||
return error::SUCCESS;
|
||||
}
|
||||
|
||||
error handle::status() const
|
||||
|
@ -1200,6 +1216,33 @@ error server::handle_cmd(client_state *state, uint32_t cmd, uint32_t args[HWSTUB
|
|||
debug() << "[net::srv::cmd] <-- WRITE\n";
|
||||
return error::SUCCESS;
|
||||
}
|
||||
/* HWSERVER_EXEC */
|
||||
else if(cmd == HWSERVER_EXEC)
|
||||
{
|
||||
uint32_t hid = args[0];
|
||||
uint32_t addr = args[1];
|
||||
uint32_t flags = args[2];
|
||||
debug() << "[net::srv::cmd] --> EXEC(" << hid << ",0x" << std::hex << addr << ","
|
||||
<< "0x" << std::hex << flags << ")\n";
|
||||
/* check ID is valid */
|
||||
auto it = state->handle_map.find(hid);
|
||||
if(it == state->handle_map.end())
|
||||
{
|
||||
debug() << "[net::srv::cmd] unknown handle ID\n";
|
||||
debug() << "[net::srv::cmd] <-- EXEC (error)\n";
|
||||
return error::ERROR;
|
||||
}
|
||||
/* exec */
|
||||
error err = it->second->exec(addr, flags);
|
||||
if(err != error::SUCCESS)
|
||||
{
|
||||
debug() << "[net::srv::cmd] cannot write: " << error_string(err) << "\n";
|
||||
debug() << "[net::srv::cmd] <-- EXEC (error)\n";
|
||||
return err;
|
||||
}
|
||||
debug() << "[net::srv::cmd] <-- EXEC\n";
|
||||
return error::SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug() << "[net::srv::cmd] <-> unknown cmd (0x" << std::hex << cmd << ")\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue