diff options
Diffstat (limited to 'utils/hwstub/tools')
-rw-r--r-- | utils/hwstub/tools/hwstub_shell.cpp | 42 |
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 | |||
452 | int 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 | { |