From ff15ed743154b4afdd5d55fc1251946c17ba7131 Mon Sep 17 00:00:00 2001 From: Atheria Date: Mon, 11 Aug 2025 17:38:01 +0700 Subject: [PATCH] add some commands --- drivers/Pic.c | 2 ++ drivers/Pic.h | 2 ++ kernel/etc/Shell.c | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/Pic.c b/drivers/Pic.c index 6e12a50..6a95bac 100644 --- a/drivers/Pic.c +++ b/drivers/Pic.c @@ -1,4 +1,6 @@ #include "Pic.h" + +#include "Console.h" #include "Io.h" #define PIC1_COMMAND 0x20 diff --git a/drivers/Pic.h b/drivers/Pic.h index 37e0ad6..518b73e 100644 --- a/drivers/Pic.h +++ b/drivers/Pic.h @@ -1,7 +1,9 @@ #ifndef PIC_H #define PIC_H #include "stdint.h" + void PicInstall(); void PitInstall(); void PitSetFrequency(uint16_t hz); + #endif \ No newline at end of file diff --git a/kernel/etc/Shell.c b/kernel/etc/Shell.c index 5f13cbd..8ea863b 100644 --- a/kernel/etc/Shell.c +++ b/kernel/etc/Shell.c @@ -9,6 +9,7 @@ #include "PS2.h" #include "Packet.h" #include "Panic.h" +#include "Pic.h" #include "Process.h" #include "RTL8139.h" #include "StringOps.h" @@ -29,7 +30,8 @@ static void Version() { void info(void) { if (!VBEIsInitialized()) return; VBEShowInfo(); - Yield(); + int count = 100; + while (count--) Yield(); } static char* GetArg(const char* cmd, int arg_num) { @@ -165,6 +167,7 @@ static void show_help() { PrintKernel(" sched - Show scheduler state\n"); PrintKernel(" perf - Show performance stats\n"); PrintKernel(" memstat - Show memory statistics\n"); + PrintKernel(" setfreq - Set PIT timer \n"); PrintKernel(" pciscan - Perform a PCI scan\n"); PrintKernel(" arptest - Perform an ARP test and send packets\n"); PrintKernel(" clear - Clear screen\n"); @@ -219,6 +222,18 @@ static void ExecuteCommand(const char* cmd) { return; } KernelMemoryAlloc((uint32_t)size); + } else if (FastStrCmp(cmd_name, "setfreq") == 0) { + char* freq_str = GetArg(cmd, 1); + if (!freq_str) { + PrintKernel("Usage: setfreq \n"); + return; + } + const uint16_t freq = atoi(freq_str); + if (freq <= 0) { + PrintKernel("Usage: setfreq \n"); + return; + } + PitSetFrequency(freq); } else if (FastStrCmp(cmd_name, "panic") == 0) { char* str = GetArg(cmd, 1); if (!str) {