summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorPrakxo <87568477+Prakxo@users.noreply.github.com>2023-08-16 17:51:20 +0100
committerGitHub <noreply@github.com>2023-08-16 09:51:20 -0700
commit0378b87aeef5abc58df7fd0a7c145a21342a1470 (patch)
tree2f5f9eab2a2ac1e94a99ea36b5de12a3d40dde46 /src/boot
parenta2deca64d24427d6856dc5e7fc43bde4b1641a43 (diff)
sleep OK (#52)
* sleep OK * add array_count macro
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/libc64/sleep.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/boot/libc64/sleep.c b/src/boot/libc64/sleep.c
new file mode 100644
index 0000000..ff1be8a
--- /dev/null
+++ b/src/boot/libc64/sleep.c
@@ -0,0 +1,28 @@
+#include "libc64/sleep.h"
+#include "macros.h"
+
+void csleep(OSTime t) {
+ OSMesgQueue mq;
+ OSMesg msg[1];
+ OSTimer timer;
+
+ osCreateMesgQueue(&mq, msg, ARRAY_COUNT(msg));
+ osSetTimer(&timer, t, 0, &mq, NULL);
+ osRecvMesg(&mq, NULL, OS_MESG_BLOCK);
+}
+
+void nsleep(u32 t) {
+ csleep(OS_NSEC_TO_CYCLES(t));
+}
+
+void usleep(u32 t) {
+ csleep(OS_USEC_TO_CYCLES(t));
+}
+
+void msleep(u32 t) {
+ csleep((t * OS_CPU_COUNTER) / 1000ULL);
+}
+
+void sleep(u32 t) {
+ csleep(t * OS_CPU_COUNTER);
+}