From 2ae20fbc4d1c0d47f9266a30580e7f35b367c25e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 19 Jun 2016 19:06:32 +0800 Subject: [PATCH] runtime: cleanup now_init/now_save --- artiq/runtime/ksupport.c | 77 ++++++++++++++++++++-------------------- artiq/runtime/ksupport.h | 2 -- 2 files changed, 38 insertions(+), 41 deletions(-) diff --git a/artiq/runtime/ksupport.c b/artiq/runtime/ksupport.c index d6c087de9..13c89f690 100644 --- a/artiq/runtime/ksupport.c +++ b/artiq/runtime/ksupport.c @@ -335,6 +335,38 @@ void exception_handler(unsigned long vect, unsigned long *regs, vect, pc, ea); } +static void now_init(void) +{ + struct msg_base request; + struct msg_now_init_reply *reply; + + request.type = MESSAGE_TYPE_NOW_INIT_REQUEST; + mailbox_send_and_wait(&request); + + reply = mailbox_wait_and_receive(); + if(reply->type != MESSAGE_TYPE_NOW_INIT_REPLY) { + core_log("Malformed MESSAGE_TYPE_NOW_INIT_REQUEST reply type %d\n", + reply->type); + while(1); + } + now = reply->now; + mailbox_acknowledge(); + + if(now < 0) { + rtio_init(); + now = rtio_get_counter() + (272000 << CONFIG_RTIO_FINE_TS_WIDTH); + } +} + +static void now_save(void) +{ + struct msg_now_save request; + + request.type = MESSAGE_TYPE_NOW_SAVE; + request.now = now; + mailbox_send_and_wait(&request); +} + int main(void); int main(void) { @@ -368,9 +400,9 @@ int main(void) mailbox_send_and_wait(&load_reply); - now = now_init(); + now_init(); kernel_run(); - now_save(now); + now_save(); attribute_writeback(typeinfo); @@ -387,7 +419,8 @@ int main(void) /* called from __artiq_personality */ void __artiq_terminate(struct artiq_exception *artiq_exn, struct artiq_backtrace_item *backtrace, - size_t backtrace_size) { + size_t backtrace_size) +{ struct msg_exception msg; msg.type = MESSAGE_TYPE_EXCEPTION; @@ -399,46 +432,12 @@ void __artiq_terminate(struct artiq_exception *artiq_exn, while(1); } -void ksupport_abort() { +void ksupport_abort() +{ artiq_raise_from_c("InternalError", "abort() called; check device log for details", 0, 0, 0); } -long long int now_init(void) -{ - struct msg_base request; - struct msg_now_init_reply *reply; - long long int now; - - request.type = MESSAGE_TYPE_NOW_INIT_REQUEST; - mailbox_send_and_wait(&request); - - reply = mailbox_wait_and_receive(); - if(reply->type != MESSAGE_TYPE_NOW_INIT_REPLY) { - core_log("Malformed MESSAGE_TYPE_NOW_INIT_REQUEST reply type %d\n", - reply->type); - while(1); - } - now = reply->now; - mailbox_acknowledge(); - - if(now < 0) { - rtio_init(); - now = rtio_get_counter() + (272000 << CONFIG_RTIO_FINE_TS_WIDTH); - } - - return now; -} - -void now_save(long long int now) -{ - struct msg_now_save request; - - request.type = MESSAGE_TYPE_NOW_SAVE; - request.now = now; - mailbox_send_and_wait(&request); -} - int watchdog_set(int ms) { struct msg_watchdog_set_request request; diff --git a/artiq/runtime/ksupport.h b/artiq/runtime/ksupport.h index c14128456..fc3ef7662 100644 --- a/artiq/runtime/ksupport.h +++ b/artiq/runtime/ksupport.h @@ -6,8 +6,6 @@ struct artiq_list { int32_t *elements; }; -long long int now_init(void); -void now_save(long long int now); int watchdog_set(int ms); void watchdog_clear(int id); void send_rpc(int service, const char *tag, ...);