WISP ERT (Client)  1.0.0
The WISP Extended Runtime (WISP side)
runtime.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdint.h>
4 #include <wio.h>
5 #include <wtp.h>
6 #include <ert/urpc.h>
7 #include <ucontext.h>
8 
9 //=== ERT async marcos ===
11 #define ERT_AWAIT(status_var, result_type, result_var, func_name, ...) { \
12  func_name(__VA_ARGS__, NULL, ert_user_resume); \
13  ert_user_suspend(&status_var, sizeof(result_type), &result_var); \
14  }
15 
16 //=== ERT types ===
19 
20 //=== ERT constants ===
22 #define _ERT_BW_SIZE 0x20
23 static const uint8_t ERT_BW_SIZE = _ERT_BW_SIZE;
26 static const uint8_t ERT_EPC_SIZE = 12;
28 static const uint8_t ERT_WISP_CLASS = 0x10;
30 static const uint16_t ERT_USER_STACK_SIZE = 200;
31 
32 //=== ERT error codes ===
34 static const uint8_t ERT_ERR_SYS_FAILED = 0x30;
35 
36 //=== ERT variables ===
38 extern wtp_t* ert_wtp_ep;
40 extern urpc_t* ert_rpc_ep;
41 
42 //=== ERT runtime APIs ===
46 extern void __attribute__((weak)) ert_pre_init();
47 
51 extern void __attribute__((weak)) ert_main();
52 
60 extern void ert_user_suspend(
61  ert_status_t* _status_var,
62  uint16_t result_size,
63  void* _result_var
64 );
65 
69 extern WIO_CALLBACK(ert_user_resume);
70 
74 extern void main(void);
wio_status_t ert_status_t
ERT status type.
Definition: runtime.h:18
uint8_t wio_status_t
WIO status type.
Definition: defs.h:40
static const uint8_t ERT_BW_SIZE
BlockWrite data buffer size.
Definition: runtime.h:24
WTP endpoint type.
Definition: endpoint.h:8
static const uint8_t ERT_WISP_CLASS
WISP class.
Definition: runtime.h:28
void ert_main()
Definition: main.c:8
static const uint16_t ERT_USER_STACK_SIZE
ERT user stack size.
Definition: runtime.h:30
void __attribute__((weak)) ert_pre_init()
ERT pre-init hook.
#define _ERT_BW_SIZE
BlockWrite data buffer size (Marco)
Definition: runtime.h:22
void main(void)
WISP program entry point.
Definition: main.c:34
void ert_user_suspend(ert_status_t *_status_var, uint16_t result_size, void *_result_var)
Suspend execution of user context.
Definition: runtime.c:118
static const uint8_t ERT_EPC_SIZE
EPC size.
Definition: runtime.h:26
urpc_t * ert_rpc_ep
ERT u-RPC endpoint.
Definition: runtime.c:14
WIO_CALLBACK(ert_user_resume)
Definition: runtime.c:136
static const uint8_t ERT_ERR_SYS_FAILED
Error code for failed remote system call.
Definition: runtime.h:34
wtp_t * ert_wtp_ep
ERT WTP endpoint.
Definition: runtime.c:12