forked from M-Labs/artiq
1
0
Fork 0

Remove lognonl(); rename log() to core_log() to avoid math.h conflict.

Also, make core_log() exactly equivalent to printf(), since the lack
of a drop-in universally usable printf() equivalent annoys me.

Note that this breaks compiled experiments. They'll be fixed in
the following commits.
This commit is contained in:
whitequark 2016-02-14 22:54:54 +00:00
parent c63afae875
commit cd7f12e4b1
13 changed files with 110 additions and 149 deletions

View File

@ -91,7 +91,7 @@ void analyzer_end(void)
int analyzer_input(void *data, int length) int analyzer_input(void *data, int length)
{ {
log("no input should be received by analyzer, dropping connection"); core_log("no input should be received by analyzer, dropping connection\n");
return -1; return -1;
} }

View File

@ -60,7 +60,7 @@ int watchdog_set(int ms)
break; break;
} }
if(id < 0) { if(id < 0) {
log("WARNING: Failed to add watchdog"); core_log("WARNING: Failed to add watchdog\n");
return id; return id;
} }

View File

@ -95,7 +95,7 @@ static void dds_set_one(long long int now, long long int ref_time, unsigned int
unsigned int channel_enc; unsigned int channel_enc;
if(channel >= CONFIG_DDS_CHANNEL_COUNT) { if(channel >= CONFIG_DDS_CHANNEL_COUNT) {
log("Attempted to set invalid DDS channel"); core_log("Attempted to set invalid DDS channel\n");
return; return;
} }
#ifdef CONFIG_DDS_ONEHOT_SEL #ifdef CONFIG_DDS_ONEHOT_SEL

View File

@ -63,21 +63,24 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
return 0; return 0;
if(record->size < 6) { if(record->size < 6) {
log("flash_storage might be corrupted: record size is %u (<6) at address %08x", record->size, record->raw_record); core_log("flash_storage might be corrupted: record size is %u (<6) at address %08x\n",
record->size, record->raw_record);
if(fatal) if(fatal)
*fatal = 1; *fatal = 1;
return 0; return 0;
} }
if(is->seek > is->buf_len - sizeof(record->size) - 2) { /* 2 is the minimum key length */ if(is->seek > is->buf_len - sizeof(record->size) - 2) { /* 2 is the minimum key length */
log("flash_storage might be corrupted: END_MARKER missing at the end of the storage sector"); core_log("flash_storage might be corrupted: END_MARKER missing at the end of "
"the storage sector\n");
if(fatal) if(fatal)
*fatal = 1; *fatal = 1;
return 0; return 0;
} }
if(record->size > is->buf_len - is->seek) { if(record->size > is->buf_len - is->seek) {
log("flash_storage might be corrupted: invalid record_size %d at address %08x", record->size, record->raw_record); core_log("flash_storage might be corrupted: invalid record_size %d at address %08x\n",
record->size, record->raw_record);
if(fatal) if(fatal)
*fatal = 1; *fatal = 1;
return 0; return 0;
@ -87,7 +90,8 @@ static int record_iter_next(struct iter_state *is, struct record *record, int *f
record->key_len = strnlen(record->key, record->size - sizeof(record->size)) + 1; record->key_len = strnlen(record->key, record->size - sizeof(record->size)) + 1;
if(record->key_len == record->size - sizeof(record->size) + 1) { if(record->key_len == record->size - sizeof(record->size) + 1) {
log("flash_storage might be corrupted: invalid key length at address %08x", record->raw_record); core_log("flash_storage might be corrupted: invalid key length at address %08x\n",
record->raw_record);
if(fatal) if(fatal)
*fatal = 1; *fatal = 1;
return 0; return 0;
@ -261,7 +265,7 @@ int fs_write(const char *key, const void *buffer, unsigned int buf_len)
return 0; // Storage is definitely full. return 0; // Storage is definitely full.
fatal_error: fatal_error:
log("fatal error: flash storage might be corrupted"); core_log("fatal error: flash storage might be corrupted\n");
return 0; return 0;
} }
@ -292,7 +296,7 @@ unsigned int fs_read(const char *key, void *buffer, unsigned int buf_len, unsign
} }
if(fatal) if(fatal)
log("fatal error: flash storage might be corrupted"); core_log("fatal error: flash storage might be corrupted\n");
return read_length; return read_length;
} }

View File

@ -45,12 +45,12 @@ static int load_or_start_kernel(const void *library, int run_kernel)
mailbox_acknowledge(); mailbox_acknowledge();
if(reply->type != MESSAGE_TYPE_LOAD_REPLY) { if(reply->type != MESSAGE_TYPE_LOAD_REPLY) {
log("BUG: unexpected reply to load/run request"); core_log("BUG: unexpected reply to load/run request\n");
return 0; return 0;
} }
if(reply->error != NULL) { if(reply->error != NULL) {
log("cannot load kernel: %s", reply->error); core_log("cannot load kernel: %s\n", reply->error);
return 0; return 0;
} }
@ -60,7 +60,7 @@ static int load_or_start_kernel(const void *library, int run_kernel)
int kloader_load_library(const void *library) int kloader_load_library(const void *library)
{ {
if(!kernel_cpu_reset_read()) { if(!kernel_cpu_reset_read()) {
log("BUG: attempted to load kernel library while kernel CPU is running"); core_log("BUG: attempted to load kernel library while kernel CPU is running\n");
return 0; return 0;
} }
@ -99,7 +99,7 @@ static int kloader_start_flash_kernel(char *key)
return 0; return 0;
if(remain) { if(remain) {
log("ERROR: kernel %s is too large", key); core_log("ERROR: kernel %s is too large\n", key);
return 0; return 0;
} }
@ -129,7 +129,7 @@ int kloader_validate_kpointer(void *p)
{ {
unsigned int v = (unsigned int)p; unsigned int v = (unsigned int)p;
if((v < KERNELCPU_EXEC_ADDRESS) || (v > KERNELCPU_LAST_ADDRESS)) { if((v < KERNELCPU_EXEC_ADDRESS) || (v > KERNELCPU_LAST_ADDRESS)) {
log("Received invalid pointer from kernel CPU: 0x%08x", v); core_log("Received invalid pointer from kernel CPU: 0x%08x\n", v);
return 0; return 0;
} }
return 1; return 1;
@ -178,11 +178,7 @@ void kloader_service_essential_kmsg(void)
case MESSAGE_TYPE_LOG: { case MESSAGE_TYPE_LOG: {
struct msg_log *msg = (struct msg_log *)umsg; struct msg_log *msg = (struct msg_log *)umsg;
if(msg->no_newline) { core_log_va(msg->fmt, msg->args);
lognonl_va(msg->fmt, msg->args);
} else {
log_va(msg->fmt, msg->args);
}
mailbox_acknowledge(); mailbox_acknowledge();
break; break;
} }

View File

@ -102,8 +102,7 @@ static const struct symbol runtime_exports[] = {
{"watchdog_set", &watchdog_set}, {"watchdog_set", &watchdog_set},
{"watchdog_clear", &watchdog_clear}, {"watchdog_clear", &watchdog_clear},
{"log", &log}, {"core_log", &core_log},
{"lognonl", &lognonl},
{"send_rpc", &send_rpc}, {"send_rpc", &send_rpc},
{"recv_rpc", &recv_rpc}, {"recv_rpc", &recv_rpc},
@ -164,7 +163,6 @@ int fprintf(FILE *stream, const char *fmt, ...)
request.type = MESSAGE_TYPE_LOG; request.type = MESSAGE_TYPE_LOG;
request.fmt = fmt; request.fmt = fmt;
request.no_newline = 1;
va_start(request.args, fmt); va_start(request.args, fmt);
mailbox_send_and_wait(&request); mailbox_send_and_wait(&request);
va_end(request.args); va_end(request.args);
@ -309,7 +307,7 @@ long long int now_init(void)
reply = mailbox_wait_and_receive(); reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_NOW_INIT_REPLY) { if(reply->type != MESSAGE_TYPE_NOW_INIT_REPLY) {
log("Malformed MESSAGE_TYPE_NOW_INIT_REQUEST reply type %d", core_log("Malformed MESSAGE_TYPE_NOW_INIT_REQUEST reply type %d\n",
reply->type); reply->type);
while(1); while(1);
} }
@ -345,7 +343,7 @@ int watchdog_set(int ms)
reply = mailbox_wait_and_receive(); reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_WATCHDOG_SET_REPLY) { if(reply->type != MESSAGE_TYPE_WATCHDOG_SET_REPLY) {
log("Malformed MESSAGE_TYPE_WATCHDOG_SET_REQUEST reply type %d", core_log("Malformed MESSAGE_TYPE_WATCHDOG_SET_REQUEST reply type %d\n",
reply->type); reply->type);
while(1); while(1);
} }
@ -389,7 +387,7 @@ int recv_rpc(void *slot) {
reply = mailbox_wait_and_receive(); reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_RPC_RECV_REPLY) { if(reply->type != MESSAGE_TYPE_RPC_RECV_REPLY) {
log("Malformed MESSAGE_TYPE_RPC_RECV_REQUEST reply type %d", core_log("Malformed MESSAGE_TYPE_RPC_RECV_REQUEST reply type %d\n",
reply->type); reply->type);
while(1); while(1);
} }
@ -458,7 +456,7 @@ struct artiq_list cache_get(const char *key)
reply = mailbox_wait_and_receive(); reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_CACHE_GET_REPLY) { if(reply->type != MESSAGE_TYPE_CACHE_GET_REPLY) {
log("Malformed MESSAGE_TYPE_CACHE_GET_REQUEST reply type %d", core_log("Malformed MESSAGE_TYPE_CACHE_GET_REQUEST reply type %d\n",
reply->type); reply->type);
while(1); while(1);
} }
@ -479,7 +477,7 @@ void cache_put(const char *key, struct artiq_list value)
reply = mailbox_wait_and_receive(); reply = mailbox_wait_and_receive();
if(reply->type != MESSAGE_TYPE_CACHE_PUT_REPLY) { if(reply->type != MESSAGE_TYPE_CACHE_PUT_REPLY) {
log("Malformed MESSAGE_TYPE_CACHE_PUT_REQUEST reply type %d", core_log("Malformed MESSAGE_TYPE_CACHE_PUT_REQUEST reply type %d\n",
reply->type); reply->type);
while(1); while(1);
} }
@ -491,25 +489,12 @@ void cache_put(const char *key, struct artiq_list value)
} }
} }
void lognonl(const char *fmt, ...) void core_log(const char *fmt, ...)
{ {
struct msg_log request; struct msg_log request;
request.type = MESSAGE_TYPE_LOG; request.type = MESSAGE_TYPE_LOG;
request.fmt = fmt; request.fmt = fmt;
request.no_newline = 1;
va_start(request.args, fmt);
mailbox_send_and_wait(&request);
va_end(request.args);
}
void log(const char *fmt, ...)
{
struct msg_log request;
request.type = MESSAGE_TYPE_LOG;
request.fmt = fmt;
request.no_newline = 0;
va_start(request.args, fmt); va_start(request.args, fmt);
mailbox_send_and_wait(&request); mailbox_send_and_wait(&request);
va_end(request.args); va_end(request.args);

View File

@ -14,7 +14,6 @@ void send_rpc(int service, const char *tag, ...);
int recv_rpc(void *slot); int recv_rpc(void *slot);
struct artiq_list cache_get(const char *key); struct artiq_list cache_get(const char *key);
void cache_put(const char *key, struct artiq_list value); void cache_put(const char *key, struct artiq_list value);
void lognonl(const char *fmt, ...); void core_log(const char *fmt, ...);
void log(const char *fmt, ...);
#endif /* __KSTARTUP_H */ #endif /* __KSTARTUP_H */

View File

@ -7,18 +7,26 @@
#include "log.h" #include "log.h"
static int buffer_index; static int buffer_cursor;
static char buffer[LOG_BUFFER_SIZE]; static char buffer[LOG_BUFFER_SIZE];
void lognonl_va(const char *fmt, va_list args) void core_log(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
core_log_va(fmt, args);
va_end(args);
}
void core_log_va(const char *fmt, va_list args)
{ {
char outbuf[256]; char outbuf[256];
int i, len; int len = vscnprintf(outbuf, sizeof(outbuf), fmt, args);
len = vscnprintf(outbuf, sizeof(outbuf), fmt, args); for(int i = 0; i < len; i++) {
for(i=0;i<len;i++) { buffer[buffer_cursor] = outbuf[i];
buffer[buffer_index] = outbuf[i]; buffer_cursor = (buffer_cursor + 1) % LOG_BUFFER_SIZE;
buffer_index = (buffer_index + 1) % LOG_BUFFER_SIZE;
} }
#ifdef CSR_ETHMAC_BASE #ifdef CSR_ETHMAC_BASE
@ -28,42 +36,16 @@ void lognonl_va(const char *fmt, va_list args)
#endif #endif
} }
void lognonl(const char *fmt, ...) void core_log_get(char *outbuf)
{ {
va_list args; int j = buffer_cursor;
for(int i = 0; i < LOG_BUFFER_SIZE; i++) {
va_start(args, fmt);
lognonl_va(fmt, args);
va_end(args);
}
void log_va(const char *fmt, va_list args)
{
lognonl_va(fmt, args);
lognonl("\n");
}
void log(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
log_va(fmt, args);
va_end(args);
}
void log_get(char *outbuf)
{
int i, j;
j = buffer_index;
for(i = 0; i < LOG_BUFFER_SIZE; i++) {
outbuf[i] = buffer[j]; outbuf[i] = buffer[j];
j = (j + 1) % LOG_BUFFER_SIZE; j = (j + 1) % LOG_BUFFER_SIZE;
} }
} }
void log_clear() void core_log_clear()
{ {
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
} }

View File

@ -5,13 +5,9 @@
#define LOG_BUFFER_SIZE 4096 #define LOG_BUFFER_SIZE 4096
void lognonl_va(const char *fmt, va_list args); void core_log(const char *fmt, ...);
void lognonl(const char *fmt, ...); void core_log_va(const char *fmt, va_list args);
void core_log_get(char *outbuf);
void log_va(const char *fmt, va_list args); void core_log_clear(void);
void log(const char *fmt, ...);
void log_get(char *outbuf);
void log_clear(void);
#endif /* __LOG_H */ #endif /* __LOG_H */

View File

@ -136,7 +136,6 @@ struct msg_cache_put_reply {
struct msg_log { struct msg_log {
int type; int type;
const char *fmt; const char *fmt;
int no_newline;
va_list args; va_list args;
}; };

View File

@ -73,7 +73,7 @@ static void moninj_monitor(const ip_addr_t *addr, u16_t port)
reply_p = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct monitor_reply), PBUF_RAM); reply_p = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct monitor_reply), PBUF_RAM);
if(!reply_p) { if(!reply_p) {
log("Failed to allocate pbuf for monitor reply"); core_log("Failed to allocate pbuf for monitor reply\n");
return; return;
} }
memcpy(reply_p->payload, &reply, sizeof(struct monitor_reply)); memcpy(reply_p->payload, &reply, sizeof(struct monitor_reply));
@ -112,7 +112,7 @@ static void moninj_ttlset(int channel, int mode)
rtio_moninj_inj_value_write(1); rtio_moninj_inj_value_write(1);
break; break;
default: default:
log("unknown TTL mode %d", mode); core_log("unknown TTL mode %d\n", mode);
break; break;
} }
} }
@ -143,7 +143,7 @@ void moninj_init(void)
{ {
listen_pcb = udp_new(); listen_pcb = udp_new();
if(!listen_pcb) { if(!listen_pcb) {
log("Failed to create UDP listening PCB"); core_log("Failed to create UDP listening PCB\n");
return; return;
} }
udp_bind(listen_pcb, IP_ADDR_ANY, 3250); udp_bind(listen_pcb, IP_ADDR_ANY, 3250);

View File

@ -17,17 +17,17 @@ void rtiocrg_init(void)
clk = 0; clk = 0;
fs_read("startup_clock", &b, 1, NULL); fs_read("startup_clock", &b, 1, NULL);
if(b == 'i') if(b == 'i')
log("Startup RTIO clock: internal"); core_log("Startup RTIO clock: internal\n");
else if(b == 'e') { else if(b == 'e') {
log("Startup RTIO clock: external"); core_log("Startup RTIO clock: external\n");
clk = 1; clk = 1;
} else } else
log("ERROR: unrecognized startup_clock entry in flash storage"); core_log("ERROR: unrecognized startup_clock entry in flash storage\n");
if(!rtiocrg_switch_clock(clk)) { if(!rtiocrg_switch_clock(clk)) {
log("ERROR: startup RTIO clock failed"); core_log("ERROR: startup RTIO clock failed\n");
log("WARNING: this may cause the system initialization to fail"); core_log("WARNING: this may cause the system initialization to fail\n");
log("WARNING: fix clocking and reset the device"); core_log("WARNING: fix clocking and reset the device\n");
} }
} }

View File

@ -95,7 +95,7 @@ static int in_packet_fill(uint8_t *data, int length)
return -1; return -1;
if(buffer_in_read_cursor < buffer_in_write_cursor) { if(buffer_in_read_cursor < buffer_in_write_cursor) {
log("session.c: read underrun (%d bytes remaining)", core_log("session.c: read underrun (%d bytes remaining)\n",
buffer_in_write_cursor - buffer_in_read_cursor); buffer_in_write_cursor - buffer_in_read_cursor);
} }
@ -109,8 +109,8 @@ static int in_packet_fill(uint8_t *data, int length)
static void in_packet_chunk(void *ptr, int length) static void in_packet_chunk(void *ptr, int length)
{ {
if(buffer_in_read_cursor + length > buffer_in_write_cursor) { if(buffer_in_read_cursor + length > buffer_in_write_cursor) {
log("session.c: read overrun while trying to read %d bytes" core_log("session.c: read overrun while trying to read %d bytes"
" (%d remaining)", " (%d remaining)\n",
length, buffer_in_write_cursor - buffer_in_read_cursor); length, buffer_in_write_cursor - buffer_in_read_cursor);
} }
@ -153,7 +153,7 @@ static const char *in_packet_string()
int length; int length;
const char *string = in_packet_bytes(&length); const char *string = in_packet_bytes(&length);
if(string[length - 1] != 0) { if(string[length - 1] != 0) {
log("session.c: string is not zero-terminated"); core_log("session.c: string is not zero-terminated\n");
return ""; return "";
} }
return string; return string;
@ -198,8 +198,8 @@ static void out_packet_extract(void **data, int *length)
static void out_packet_advance_consumed(int length) static void out_packet_advance_consumed(int length)
{ {
if(buffer_out_read_cursor + length > buffer_out_write_cursor) { if(buffer_out_read_cursor + length > buffer_out_write_cursor) {
log("session.c: write underrun (consume) while trying to" core_log("session.c: write underrun (consume) while trying to"
" acknowledge %d bytes (%d remaining)", " acknowledge %d bytes (%d remaining)\n",
length, buffer_out_write_cursor - buffer_out_read_cursor); length, buffer_out_write_cursor - buffer_out_read_cursor);
return; return;
} }
@ -210,8 +210,8 @@ static void out_packet_advance_consumed(int length)
static void out_packet_advance_sent(int length) static void out_packet_advance_sent(int length)
{ {
if(buffer_out_sent_cursor + length > buffer_out_write_cursor) { if(buffer_out_sent_cursor + length > buffer_out_write_cursor) {
log("session.c: write underrun (send) while trying to" core_log("session.c: write underrun (send) while trying to"
" acknowledge %d bytes (%d remaining)", " acknowledge %d bytes (%d remaining)\n",
length, buffer_out_write_cursor - buffer_out_sent_cursor); length, buffer_out_write_cursor - buffer_out_sent_cursor);
return; return;
} }
@ -224,8 +224,8 @@ static void out_packet_advance_sent(int length)
static int out_packet_chunk(const void *ptr, int length) static int out_packet_chunk(const void *ptr, int length)
{ {
if(buffer_out_write_cursor + length > BUFFER_OUT_SIZE) { if(buffer_out_write_cursor + length > BUFFER_OUT_SIZE) {
log("session.c: write overrun while trying to write %d bytes" core_log("session.c: write overrun while trying to write %d bytes"
" (%d remaining)", " (%d remaining)\n",
length, BUFFER_OUT_SIZE - buffer_out_write_cursor); length, BUFFER_OUT_SIZE - buffer_out_write_cursor);
return 0; return 0;
} }
@ -305,7 +305,7 @@ void session_startup_kernel(void)
if(!kloader_start_startup_kernel()) if(!kloader_start_startup_kernel())
return; return;
log("Startup kernel started"); core_log("Startup kernel started\n");
while(1) { while(1) {
kloader_service_essential_kmsg(); kloader_service_essential_kmsg();
@ -318,21 +318,21 @@ void session_startup_kernel(void)
if(umsg->type == MESSAGE_TYPE_FINISHED) if(umsg->type == MESSAGE_TYPE_FINISHED)
break; break;
else if(umsg->type == MESSAGE_TYPE_EXCEPTION) { else if(umsg->type == MESSAGE_TYPE_EXCEPTION) {
log("WARNING: startup kernel ended with exception"); core_log("WARNING: startup kernel ended with exception\n");
break; break;
} else { } else {
log("ERROR: received invalid message type from kernel CPU"); core_log("ERROR: received invalid message type from kernel CPU\n");
break; break;
} }
} }
if(watchdog_expired()) { if(watchdog_expired()) {
log("WARNING: watchdog expired in startup kernel"); core_log("WARNING: watchdog expired in startup kernel\n");
break; break;
} }
} }
kloader_stop(); kloader_stop();
log("Startup kernel terminated"); core_log("Startup kernel terminated\n");
} }
void session_start(void) void session_start(void)
@ -416,7 +416,7 @@ static int process_input(void)
int clk = in_packet_int8(); int clk = in_packet_int8();
if(user_kernel_state >= USER_KERNEL_RUNNING) { if(user_kernel_state >= USER_KERNEL_RUNNING) {
log("Attempted to switch RTIO clock while kernel running"); core_log("Attempted to switch RTIO clock while kernel running\n");
out_packet_empty(REMOTEMSG_TYPE_CLOCK_SWITCH_FAILED); out_packet_empty(REMOTEMSG_TYPE_CLOCK_SWITCH_FAILED);
break; break;
} }
@ -433,13 +433,13 @@ static int process_input(void)
#error Output buffer cannot hold the log buffer #error Output buffer cannot hold the log buffer
#endif #endif
out_packet_start(REMOTEMSG_TYPE_LOG_REPLY); out_packet_start(REMOTEMSG_TYPE_LOG_REPLY);
log_get(&buffer_out.data[buffer_out_write_cursor]); core_log_get(&buffer_out.data[buffer_out_write_cursor]);
buffer_out_write_cursor += LOG_BUFFER_SIZE; buffer_out_write_cursor += LOG_BUFFER_SIZE;
out_packet_finish(); out_packet_finish();
break; break;
case REMOTEMSG_TYPE_LOG_CLEAR: case REMOTEMSG_TYPE_LOG_CLEAR:
log_clear(); core_log_clear();
out_packet_empty(REMOTEMSG_TYPE_LOG_REPLY); out_packet_empty(REMOTEMSG_TYPE_LOG_REPLY);
break; break;
@ -492,7 +492,7 @@ static int process_input(void)
buffer_in_read_cursor = buffer_in_write_cursor; buffer_in_read_cursor = buffer_in_write_cursor;
if(user_kernel_state >= USER_KERNEL_RUNNING) { if(user_kernel_state >= USER_KERNEL_RUNNING) {
log("Attempted to load new kernel library while already running"); core_log("Attempted to load new kernel library while already running\n");
out_packet_empty(REMOTEMSG_TYPE_LOAD_FAILED); out_packet_empty(REMOTEMSG_TYPE_LOAD_FAILED);
break; break;
} }
@ -508,7 +508,7 @@ static int process_input(void)
case REMOTEMSG_TYPE_RUN_KERNEL: case REMOTEMSG_TYPE_RUN_KERNEL:
if(user_kernel_state != USER_KERNEL_LOADED) { if(user_kernel_state != USER_KERNEL_LOADED) {
log("Attempted to run kernel while not in the LOADED state"); core_log("Attempted to run kernel while not in the LOADED state\n");
out_packet_empty(REMOTEMSG_TYPE_KERNEL_STARTUP_FAILED); out_packet_empty(REMOTEMSG_TYPE_KERNEL_STARTUP_FAILED);
break; break;
} }
@ -524,13 +524,13 @@ static int process_input(void)
struct msg_rpc_recv_reply reply; struct msg_rpc_recv_reply reply;
if(user_kernel_state != USER_KERNEL_WAIT_RPC) { if(user_kernel_state != USER_KERNEL_WAIT_RPC) {
log("Unsolicited RPC reply"); core_log("Unsolicited RPC reply\n");
return 0; // restart session return 0; // restart session
} }
request = mailbox_wait_and_receive(); request = mailbox_wait_and_receive();
if(request->type != MESSAGE_TYPE_RPC_RECV_REQUEST) { if(request->type != MESSAGE_TYPE_RPC_RECV_REQUEST) {
log("Expected MESSAGE_TYPE_RPC_RECV_REQUEST, got %d", core_log("Expected MESSAGE_TYPE_RPC_RECV_REQUEST, got %d\n",
request->type); request->type);
return 0; // restart session return 0; // restart session
} }
@ -538,7 +538,7 @@ static int process_input(void)
const char *tag = in_packet_string(); const char *tag = in_packet_string();
void *slot = request->slot; void *slot = request->slot;
if(!receive_rpc_value(&tag, &slot)) { if(!receive_rpc_value(&tag, &slot)) {
log("Failed to receive RPC reply"); core_log("Failed to receive RPC reply\n");
return 0; // restart session return 0; // restart session
} }
@ -567,13 +567,13 @@ static int process_input(void)
exception.function = in_packet_string(); exception.function = in_packet_string();
if(user_kernel_state != USER_KERNEL_WAIT_RPC) { if(user_kernel_state != USER_KERNEL_WAIT_RPC) {
log("Unsolicited RPC exception reply"); core_log("Unsolicited RPC exception reply\n");
return 0; // restart session return 0; // restart session
} }
request = mailbox_wait_and_receive(); request = mailbox_wait_and_receive();
if(request->type != MESSAGE_TYPE_RPC_RECV_REQUEST) { if(request->type != MESSAGE_TYPE_RPC_RECV_REQUEST) {
log("Expected MESSAGE_TYPE_RPC_RECV_REQUEST, got %d", core_log("Expected MESSAGE_TYPE_RPC_RECV_REQUEST, got %d\n",
request->type); request->type);
return 0; // restart session return 0; // restart session
} }
@ -588,7 +588,7 @@ static int process_input(void)
} }
default: default:
log("Received invalid packet type %d from host", core_log("Received invalid packet type %d from host\n",
buffer_in.header.type); buffer_in.header.type);
return 0; return 0;
} }
@ -657,7 +657,7 @@ static int sizeof_rpc_value(const char **tag)
return sizeof_rpc_value(tag) * 3; return sizeof_rpc_value(tag) * 3;
default: default:
log("sizeof_rpc_value: unknown tag %02x", *((*tag) - 1)); core_log("sizeof_rpc_value: unknown tag %02x\n", *((*tag) - 1));
return 0; return 0;
} }
} }
@ -674,7 +674,7 @@ static void *alloc_rpc_value(int size)
request = mailbox_wait_and_receive(); request = mailbox_wait_and_receive();
if(request->type != MESSAGE_TYPE_RPC_RECV_REQUEST) { if(request->type != MESSAGE_TYPE_RPC_RECV_REQUEST) {
log("Expected MESSAGE_TYPE_RPC_RECV_REQUEST, got %d", core_log("Expected MESSAGE_TYPE_RPC_RECV_REQUEST, got %d\n",
request->type); request->type);
return NULL; return NULL;
} }
@ -766,7 +766,7 @@ static int receive_rpc_value(const char **tag, void **slot)
} }
default: default:
log("receive_rpc_value: unknown tag %02x", *((*tag) - 1)); core_log("receive_rpc_value: unknown tag %02x\n", *((*tag) - 1));
return 0; return 0;
} }
@ -834,7 +834,7 @@ static int send_rpc_value(const char **tag, void **value)
for(int i = 0; i < list->length; i++) { for(int i = 0; i < list->length; i++) {
const char *tag_copy = *tag; const char *tag_copy = *tag;
if(!send_rpc_value(&tag_copy, &element)) { if(!send_rpc_value(&tag_copy, &element)) {
log("failed to send list at element %d/%d", i, list->length); core_log("failed to send list at element %d/%d\n", i, list->length);
return 0; return 0;
} }
} }
@ -882,7 +882,7 @@ static int send_rpc_value(const char **tag, void **value)
} }
default: default:
log("send_rpc_value: unknown tag %02x", *((*tag) - 1)); core_log("send_rpc_value: unknown tag %02x\n", *((*tag) - 1));
return 0; return 0;
} }
@ -932,7 +932,7 @@ static int process_kmsg(struct msg_base *umsg)
return 1; return 1;
} }
if(user_kernel_state != USER_KERNEL_RUNNING) { if(user_kernel_state != USER_KERNEL_RUNNING) {
log("Received unexpected message from kernel CPU while not in running state"); core_log("Received unexpected message from kernel CPU while not in running state\n");
return 0; return 0;
} }
@ -986,7 +986,7 @@ static int process_kmsg(struct msg_base *umsg)
struct msg_rpc_send *msg = (struct msg_rpc_send *)umsg; struct msg_rpc_send *msg = (struct msg_rpc_send *)umsg;
if(!send_rpc_request(msg->service, msg->tag, msg->args)) { if(!send_rpc_request(msg->service, msg->tag, msg->args)) {
log("Failed to send RPC request (service %d, tag %s)", core_log("Failed to send RPC request (service %d, tag %s)\n",
msg->service, msg->tag); msg->service, msg->tag);
return 0; // restart session return 0; // restart session
} }
@ -1059,7 +1059,7 @@ static int process_kmsg(struct msg_base *umsg)
} }
default: { default: {
log("Received invalid message type %d from kernel CPU", core_log("Received invalid message type %d from kernel CPU\n",
umsg->type); umsg->type);
return 0; return 0;
} }
@ -1085,12 +1085,12 @@ void session_poll(void **data, int *length)
{ {
if(user_kernel_state == USER_KERNEL_RUNNING) { if(user_kernel_state == USER_KERNEL_RUNNING) {
if(watchdog_expired()) { if(watchdog_expired()) {
log("Watchdog expired"); core_log("Watchdog expired\n");
*length = -1; *length = -1;
return; return;
} }
if(!rtiocrg_check()) { if(!rtiocrg_check()) {
log("RTIO clock failure"); core_log("RTIO clock failure\n");
*length = -1; *length = -1;
return; return;
} }