3939#include <sys/printk.h>
4040#include <sys/ring_buffer.h>
4141#include <tvm/runtime/crt/logging.h>
42- #include <tvm/runtime/crt/utvm_rpc_server .h>
42+ #include <tvm/runtime/crt/microtvm_rpc_server .h>
4343#include <unistd.h>
4444#include <zephyr.h>
4545
@@ -146,30 +146,30 @@ tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
146146
147147#define MILLIS_TIL_EXPIRY 200
148148#define TIME_TIL_EXPIRY (K_MSEC(MILLIS_TIL_EXPIRY))
149- K_TIMER_DEFINE (g_utvm_timer , /* expiry func */ NULL , /* stop func */ NULL );
149+ K_TIMER_DEFINE (g_microtvm_timer , /* expiry func */ NULL , /* stop func */ NULL );
150150
151- uint32_t g_utvm_start_time ;
152- int g_utvm_timer_running = 0 ;
151+ uint32_t g_microtvm_start_time ;
152+ int g_microtvm_timer_running = 0 ;
153153
154154// Called to start system timer.
155155tvm_crt_error_t TVMPlatformTimerStart () {
156- if (g_utvm_timer_running ) {
156+ if (g_microtvm_timer_running ) {
157157 TVMLogf ("timer already running" );
158158 return kTvmErrorPlatformTimerBadState ;
159159 }
160160
161161#ifdef CONFIG_LED
162162 gpio_pin_set (led0_pin , LED0_PIN , 1 );
163163#endif
164- k_timer_start (& g_utvm_timer , TIME_TIL_EXPIRY , TIME_TIL_EXPIRY );
165- g_utvm_start_time = k_cycle_get_32 ();
166- g_utvm_timer_running = 1 ;
164+ k_timer_start (& g_microtvm_timer , TIME_TIL_EXPIRY , TIME_TIL_EXPIRY );
165+ g_microtvm_start_time = k_cycle_get_32 ();
166+ g_microtvm_timer_running = 1 ;
167167 return kTvmErrorNoError ;
168168}
169169
170170// Called to stop system timer.
171171tvm_crt_error_t TVMPlatformTimerStop (double * elapsed_time_seconds ) {
172- if (!g_utvm_timer_running ) {
172+ if (!g_microtvm_timer_running ) {
173173 TVMLogf ("timer not running" );
174174 return kTvmErrorSystemErrorMask | 2 ;
175175 }
@@ -180,26 +180,26 @@ tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
180180#endif
181181
182182 // compute how long the work took
183- uint32_t cycles_spent = stop_time - g_utvm_start_time ;
184- if (stop_time < g_utvm_start_time ) {
183+ uint32_t cycles_spent = stop_time - g_microtvm_start_time ;
184+ if (stop_time < g_microtvm_start_time ) {
185185 // we rolled over *at least* once, so correct the rollover it was *only*
186186 // once, because we might still use this result
187- cycles_spent = ~((uint32_t )0 ) - (g_utvm_start_time - stop_time );
187+ cycles_spent = ~((uint32_t )0 ) - (g_microtvm_start_time - stop_time );
188188 }
189189
190190 uint32_t ns_spent = (uint32_t )k_cyc_to_ns_floor64 (cycles_spent );
191191 double hw_clock_res_us = ns_spent / 1000.0 ;
192192
193193 // need to grab time remaining *before* stopping. when stopped, this function
194194 // always returns 0.
195- int32_t time_remaining_ms = k_timer_remaining_get (& g_utvm_timer );
196- k_timer_stop (& g_utvm_timer );
195+ int32_t time_remaining_ms = k_timer_remaining_get (& g_microtvm_timer );
196+ k_timer_stop (& g_microtvm_timer );
197197 // check *after* stopping to prevent extra expiries on the happy path
198198 if (time_remaining_ms < 0 ) {
199199 TVMLogf ("negative time remaining" );
200200 return kTvmErrorSystemErrorMask | 3 ;
201201 }
202- uint32_t num_expiries = k_timer_status_get (& g_utvm_timer );
202+ uint32_t num_expiries = k_timer_status_get (& g_microtvm_timer );
203203 uint32_t timer_res_ms = ((num_expiries * MILLIS_TIL_EXPIRY ) + time_remaining_ms );
204204 double approx_num_cycles =
205205 (double )k_ticks_to_cyc_floor32 (1 ) * (double )k_ms_to_ticks_ceil32 (timer_res_ms );
@@ -211,7 +211,7 @@ tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
211211 * elapsed_time_seconds = hw_clock_res_us / 1e6 ;
212212 }
213213
214- g_utvm_timer_running = 0 ;
214+ g_microtvm_timer_running = 0 ;
215215 return kTvmErrorNoError ;
216216}
217217
@@ -285,14 +285,14 @@ void main(void) {
285285 uart_rx_init (& uart_rx_rbuf , tvm_uart );
286286
287287 // Initialize microTVM RPC server, which will receive commands from the UART and execute them.
288- utvm_rpc_server_t server = UTvmRpcServerInit (write_serial , NULL );
288+ microtvm_rpc_server_t server = MicroTVMRpcServerInit (write_serial , NULL );
289289 TVMLogf ("microTVM Zephyr runtime - running" );
290290#ifdef CONFIG_LED
291291 gpio_pin_set (led0_pin , LED0_PIN , 0 );
292292#endif
293293
294294 // The main application loop. We continuously read commands from the UART
295- // and dispatch them to UTvmRpcServerLoop ().
295+ // and dispatch them to MicroTVMRpcServerLoop ().
296296 while (true) {
297297 uint8_t * data ;
298298 unsigned int key = irq_lock ();
@@ -302,7 +302,7 @@ void main(void) {
302302 size_t bytes_remaining = bytes_read ;
303303 while (bytes_remaining > 0 ) {
304304 // Pass the received bytes to the RPC server.
305- tvm_crt_error_t err = UTvmRpcServerLoop (server , & data , & bytes_remaining );
305+ tvm_crt_error_t err = MicroTVMRpcServerLoop (server , & data , & bytes_remaining );
306306 if (err != kTvmErrorNoError && err != kTvmErrorFramingShortPacket ) {
307307 TVMPlatformAbort (err );
308308 }
0 commit comments