diff options
Diffstat (limited to 'src/app/transactiontest/main.cc')
-rw-r--r-- | src/app/transactiontest/main.cc | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/app/transactiontest/main.cc b/src/app/transactiontest/main.cc index e359e67..cb2d86e 100644 --- a/src/app/transactiontest/main.cc +++ b/src/app/transactiontest/main.cc @@ -8,37 +8,31 @@ #endif extern "C" { - void asm_save_toc(); - void asm_load_toc(); + void asm_save_all(); + void asm_load_all(); + void asm_load_mem(); } -volatile bool __attribute__((section(".text"))) have_state = false; uint16_t i = 0; -void restore_state() -{ - if (!have_state) { - return; - } - asm_load_toc(); -} - -void save_state() -{ - asm_save_toc(); - have_state = true; -} +class Transaction { + public: + inline Transaction() { asm_save_all(); } + inline ~Transaction() {} + inline void retry() { asm_load_all(); } + inline void abort() { asm_load_mem(); } +}; void loop(void) { gpio.led_toggle(1); - kout << dec << i << endl; - i++; - if (i == 5) { - save_state(); - } - if (i == 10) { - restore_state(); + { + Transaction tx; + kout << dec << i << endl; + i++; + if (!gpio.read(GPIO::p4_5)) { + tx.abort(); + } } } @@ -48,15 +42,11 @@ int main(void) gpio.setup(); kout.setup(); - restore_state(); + //restore_state(); gpio.led_on(0); + gpio.input(GPIO::p4_5, 1); kout << "Hello, World!" << endl; - kout << "Test, World!" << endl; - kout << dec << uptime.get_cycles() << endl; - kout << dec << uptime.get_cycles() << endl; - kout << dec << uptime.get_cycles() << endl; - kout << dec << uptime.get_cycles() << endl; arch.idle_loop(); |