summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-08-05 18:19:08 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-09-07 17:45:56 +0200
commit0c7c54e18550f1765bece9d3ec0e7f67edde50cb (patch)
treec478bb451576570f956cee0aa9a3cac89a427c4b
parent6d13d9b718a0dd93dabe9aad48d2ccfdd94ed073 (diff)
downloadrockbox-0c7c54e18550f1765bece9d3ec0e7f67edde50cb.tar.gz
rockbox-0c7c54e18550f1765bece9d3ec0e7f67edde50cb.zip
hwstub_shell: add support for set/clr/tog without SCT using read and write
Change-Id: Ib0a5123e5cc51ee193ef761c36af63467740c670
-rw-r--r--utils/hwstub/tools/hwstub_shell.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/utils/hwstub/tools/hwstub_shell.cpp b/utils/hwstub/tools/hwstub_shell.cpp
index 2f2803da13..e5d3a72abf 100644
--- a/utils/hwstub/tools/hwstub_shell.cpp
+++ b/utils/hwstub/tools/hwstub_shell.cpp
@@ -444,7 +444,30 @@ int my_lua_write_field(lua_State *state)
444 value = value << shift | (hw_read32(state, addr) & ~(mask << shift)); 444 value = value << shift | (hw_read32(state, addr) & ~(mask << shift));
445 else 445 else
446 value <<= shift; 446 value <<= shift;
447 447
448 hw_write32(state, addr, value);
449 return 0;
450}
451
452int my_lua_sct_reg(lua_State *state)
453{
454 int n = lua_gettop(state);
455 if(n != 1)
456 luaL_error(state, "sct() takes one argument");
457 soc_addr_t addr = lua_tounsigned(state, lua_upvalueindex(1));
458 char op = lua_tounsigned(state, lua_upvalueindex(2));
459
460 soc_word_t mask = luaL_checkunsigned(state, 1);
461 soc_word_t value = hw_read32(state, addr);
462 if(op == 's')
463 value |= mask;
464 else if(op == 'c')
465 value &= ~mask;
466 else if(op == 't')
467 value ^= mask;
468 else
469 luaL_error(state, "sct() internal error");
470
448 hw_write32(state, addr, value); 471 hw_write32(state, addr, value);
449 return 0; 472 return 0;
450} 473}
@@ -558,6 +581,23 @@ void my_lua_create_reg(soc_addr_t addr, size_t index, const soc_reg_t& reg)
558 lua_pushcclosure(g_lua, my_lua_write_reg, 1); 581 lua_pushcclosure(g_lua, my_lua_write_reg, 1);
559 lua_setfield(g_lua, -2, "tog"); 582 lua_setfield(g_lua, -2, "tog");
560 } 583 }
584 else
585 {
586 lua_pushunsigned(g_lua, addr + reg.addr[index].addr);
587 lua_pushunsigned(g_lua, 's');
588 lua_pushcclosure(g_lua, my_lua_sct_reg, 2);
589 lua_setfield(g_lua, -2, "set");
590
591 lua_pushunsigned(g_lua, addr + reg.addr[index].addr);
592 lua_pushunsigned(g_lua, 'c');
593 lua_pushcclosure(g_lua, my_lua_sct_reg, 2);
594 lua_setfield(g_lua, -2, "clr");
595
596 lua_pushunsigned(g_lua, addr + reg.addr[index].addr);
597 lua_pushunsigned(g_lua, 't');
598 lua_pushcclosure(g_lua, my_lua_sct_reg, 2);
599 lua_setfield(g_lua, -2, "tog");
600 }
561 601
562 for(size_t i = 0; i < reg.field.size(); i++) 602 for(size_t i = 0; i < reg.field.size(); i++)
563 { 603 {