Files
failnix/targets/c-host/fail.c
Christoph Urlacher 28a3c37d41 update hosts for cored target
WIP: currently the hosts are not generic and don't support different
targets
2026-04-07 22:12:57 +02:00

54 lines
1.1 KiB
C

#include "../lib.h"
#include "../lib_cored.h"
void fail_start_trace(void) {}
void fail_stop_trace(void) {}
void fail_marker_positive(void) {}
void fail_marker_negative(void) {}
void fail_marker_detected(void) {}
void init_outputs(plain_t x_c, plain_t y_c, plain_t z_c);
int wasm_module(void);
enc_t get_cored_res(void);
void os_main(void) {
init_outputs(100, 142, 100);
fail_start_trace();
sign_t static_sig = wasm_module();
fail_stop_trace();
sign_t vote_result_sig;
switch (static_sig) {
case SIG_s_XYZ:
case SIG_s_XY:
case SIG_s_XZ:
vote_result_sig = SIG_X;
break;
case SIG_s_YZ:
vote_result_sig = SIG_Y;
break;
default:
break;
}
// Inversely apply constant program flow signature.
enc_t cored_res = get_cored_res();
cored_res -= static_sig;
/* Validate Vote result */
if (!check(cored_res, THE_A, vote_result_sig)) {
fail_marker_detected();
return;
}
plain_t res = decode(cored_res, THE_A, vote_result_sig);
if (res == 100) {
fail_marker_positive();
return;
} else {
fail_marker_negative();
return;
}
}