From b5353cb600a8e2f7a04fa75334d6558a1ea76ba1 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Sun, 4 Jan 2026 01:44:02 +0100 Subject: [PATCH] Auxilary scripts for formatting all components --- aux/format.sh | 7 +++++++ kernel/amd64/hpet.c | 2 +- kernel/amd64/syscall.c | 2 +- kernel/syscall/syscall.c | 2 +- libmsl/amd64/syscall.c | 33 ++++++++++++++++----------------- libmsl/amd64/syscall.h | 3 ++- libmsl/init/__premain.c | 4 ++-- libmsl/m/proc.c | 8 ++------ libmsl/m/syscall.h | 4 ++-- make/apps.mk | 5 ++++- make/user.mk | 5 ++++- 11 files changed, 42 insertions(+), 33 deletions(-) create mode 100755 aux/format.sh diff --git a/aux/format.sh b/aux/format.sh new file mode 100755 index 0000000..3e5963a --- /dev/null +++ b/aux/format.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -x + +make -B format_kernel +make -B format_libmsl +make -B format_apps diff --git a/kernel/amd64/hpet.c b/kernel/amd64/hpet.c index a3a7ad7..9ebb2aa 100644 --- a/kernel/amd64/hpet.c +++ b/kernel/amd64/hpet.c @@ -60,7 +60,7 @@ void amd64_hpet_sleep_micro (uint64_t us) { uint64_t start = amd64_hpet_timestamp (); uint64_t target_fs = us * 1000000000ULL; - + for (;;) { uint64_t current = amd64_hpet_timestamp (); uint64_t dt = current - start; diff --git a/kernel/amd64/syscall.c b/kernel/amd64/syscall.c index 137cf75..2838472 100644 --- a/kernel/amd64/syscall.c +++ b/kernel/amd64/syscall.c @@ -3,10 +3,10 @@ #include #include #include +#include #include #include #include -#include #include extern void amd64_syscall_entry (void); diff --git a/kernel/syscall/syscall.c b/kernel/syscall/syscall.c index 75b0437..e2d5405 100644 --- a/kernel/syscall/syscall.c +++ b/kernel/syscall/syscall.c @@ -1,8 +1,8 @@ #include #include +#include #include #include -#include #include #define DEFINE_SYSCALL(name) \ diff --git a/libmsl/amd64/syscall.c b/libmsl/amd64/syscall.c index 798e689..d106a7b 100644 --- a/libmsl/amd64/syscall.c +++ b/libmsl/amd64/syscall.c @@ -1,23 +1,22 @@ +#include #include #include -#include -int msl_amd64_syscall (int syscall_num, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6) { +int msl_amd64_syscall (int syscall_num, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, + uintptr_t a5, uintptr_t a6) { uint64_t result; - __asm__ volatile ( - "movq %1, %%rax\n" - "movq %2, %%rdi\n" - "movq %3, %%rsi\n" - "movq %4, %%rdx\n" - "movq %5, %%r10\n" - "movq %6, %%r8\n" - "movq %7, %%r9\n" - "syscall\n" - "movq %%rax, %0\n" - : "=r"(result) - : "r"((uint64_t)syscall_num), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), "r"(a6) - : "memory", "cc", "rcx", "r11" - ); + __asm__ volatile ("movq %1, %%rax\n" + "movq %2, %%rdi\n" + "movq %3, %%rsi\n" + "movq %4, %%rdx\n" + "movq %5, %%r10\n" + "movq %6, %%r8\n" + "movq %7, %%r9\n" + "syscall\n" + "movq %%rax, %0\n" + : "=r"(result) + : "r"((uint64_t)syscall_num), "r"(a1), "r"(a2), "r"(a3), "r"(a4), "r"(a5), + "r"(a6) + : "memory", "cc", "rcx", "r11"); return (int)result; } - diff --git a/libmsl/amd64/syscall.h b/libmsl/amd64/syscall.h index 01243aa..d4b6677 100644 --- a/libmsl/amd64/syscall.h +++ b/libmsl/amd64/syscall.h @@ -3,6 +3,7 @@ #include -int msl_amd64_syscall (int syscall_num, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6); +int msl_amd64_syscall (int syscall_num, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, + uintptr_t a5, uintptr_t a6); #endif // _LIBMSL_AMD64_SYSCALL_H diff --git a/libmsl/init/__premain.c b/libmsl/init/__premain.c index fa36727..035f52a 100644 --- a/libmsl/init/__premain.c +++ b/libmsl/init/__premain.c @@ -1,5 +1,5 @@ -#include #include +#include extern volatile uint8_t __bss_start[]; extern volatile uint8_t __bss_end[]; @@ -7,7 +7,7 @@ extern volatile uint8_t __bss_end[]; extern void app_main (void); static void msl_clear_bss (void) { - uint8_t *p = (uint8_t*)__bss_start; + uint8_t* p = (uint8_t*)__bss_start; while (p < __bss_end) { *p++ = 0; } diff --git a/libmsl/m/proc.c b/libmsl/m/proc.c index 53b9515..544fa1f 100644 --- a/libmsl/m/proc.c +++ b/libmsl/m/proc.c @@ -1,10 +1,6 @@ #include #include -int m_proc_quit (void) { - return m_syscall (SYS_PROC_QUIT, 0, 0, 0, 0, 0, 0); -} +int m_proc_quit (void) { return m_syscall (SYS_PROC_QUIT, 0, 0, 0, 0, 0, 0); } -int m_proc_test (void) { - return m_syscall (SYS_PROC_TEST, 0, 0, 0, 0, 0, 0); -} +int m_proc_test (void) { return m_syscall (SYS_PROC_TEST, 0, 0, 0, 0, 0, 0); } diff --git a/libmsl/m/syscall.h b/libmsl/m/syscall.h index 8bbd4e8..c7b7c4b 100644 --- a/libmsl/m/syscall.h +++ b/libmsl/m/syscall.h @@ -4,8 +4,8 @@ #include #if defined(__x86_64__) - #include - #define m_syscall msl_amd64_syscall +#include +#define m_syscall msl_amd64_syscall #endif #endif // _LIBMSL_M_SYSCALL_H diff --git a/make/apps.mk b/make/apps.mk index 846c922..4e7c723 100644 --- a/make/apps.mk +++ b/make/apps.mk @@ -6,4 +6,7 @@ all_apps: clean_apps: @for d in $(apps); do make -C $$d platform=$(platform) clean; done -.PHONY: all_apps clean_apps +format_apps: + @for d in $(apps); do make -C $$d platform=$(platform) format; done + +.PHONY: all_apps clean_apps format_apps diff --git a/make/user.mk b/make/user.mk index 0c9b9ab..30aa36e 100644 --- a/make/user.mk +++ b/make/user.mk @@ -23,4 +23,7 @@ $(app): $(o) clean: rm -f $(o) $(app) -.PHONY: all clean +format: + clang-format -i $$(git ls-files '*.c' '*.h') + +.PHONY: all clean format