1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  */
9 
10 #include "proc.h"
11 #include "procfs.h"
12 
13 #include <rthw.h>
14 #include <rtdbg.h>
15 
16 #include <fcntl.h>
17 #include <errno.h>
18 
19 #include <dfs_dentry.h>
20 
21 
single_show(struct dfs_seq_file * seq,void * data)22 static int single_show(struct dfs_seq_file *seq, void *data)
23 {
24     dfs_seq_printf(seq, "%lu.%02lu %lu.%02lu\n",
25                    (unsigned long)rt_tick_get_millisecond() / 1000, (unsigned long)(rt_tick_get_millisecond() % 1000) / 100,
26                    (unsigned long)rt_tick_get_millisecond() / 1000, (unsigned long)(rt_tick_get_millisecond() % 1000) / 100);
27 
28     return 0;
29 }
30 
proc_uptime_init(void)31 int proc_uptime_init(void)
32 {
33     struct proc_dentry *dentry = proc_create_single_data("uptime", 0, NULL, single_show, NULL);
34     proc_release(dentry);
35 
36     return 0;
37 }
38 INIT_ENV_EXPORT(proc_uptime_init);
39