runtime: cleanup now_init/now_save

This commit is contained in:
Sebastien Bourdeauducq 2016-06-19 19:06:32 +08:00
parent 4e241f10c5
commit 2ae20fbc4d
2 changed files with 38 additions and 41 deletions

View File

@ -335,6 +335,38 @@ void exception_handler(unsigned long vect, unsigned long *regs,
vect, pc, ea); 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);
int main(void) int main(void)
{ {
@ -368,9 +400,9 @@ int main(void)
mailbox_send_and_wait(&load_reply); mailbox_send_and_wait(&load_reply);
now = now_init(); now_init();
kernel_run(); kernel_run();
now_save(now); now_save();
attribute_writeback(typeinfo); attribute_writeback(typeinfo);
@ -387,7 +419,8 @@ int main(void)
/* called from __artiq_personality */ /* called from __artiq_personality */
void __artiq_terminate(struct artiq_exception *artiq_exn, void __artiq_terminate(struct artiq_exception *artiq_exn,
struct artiq_backtrace_item *backtrace, struct artiq_backtrace_item *backtrace,
size_t backtrace_size) { size_t backtrace_size)
{
struct msg_exception msg; struct msg_exception msg;
msg.type = MESSAGE_TYPE_EXCEPTION; msg.type = MESSAGE_TYPE_EXCEPTION;
@ -399,46 +432,12 @@ void __artiq_terminate(struct artiq_exception *artiq_exn,
while(1); while(1);
} }
void ksupport_abort() { void ksupport_abort()
{
artiq_raise_from_c("InternalError", "abort() called; check device log for details", artiq_raise_from_c("InternalError", "abort() called; check device log for details",
0, 0, 0); 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) int watchdog_set(int ms)
{ {
struct msg_watchdog_set_request request; struct msg_watchdog_set_request request;

View File

@ -6,8 +6,6 @@ struct artiq_list {
int32_t *elements; int32_t *elements;
}; };
long long int now_init(void);
void now_save(long long int now);
int watchdog_set(int ms); int watchdog_set(int ms);
void watchdog_clear(int id); void watchdog_clear(int id);
void send_rpc(int service, const char *tag, ...); void send_rpc(int service, const char *tag, ...);