From f844ed86a0fa43af21f43b808b9abd2f6f15794d Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 26 Nov 2019 17:23:55 +0100 Subject: [PATCH] Error with march (speaker) corrected --- Makefile | 5 +++++ include/io/spkr.h | 1 - kaleid/kernel/io/spkr.c | 18 +++++++++++------- kaleid/kernel/sh/shcmds.c | 27 +++++++++++++++++++++++++-- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index f75935b..1912439 100644 --- a/Makefile +++ b/Makefile @@ -194,6 +194,11 @@ $(KOBJDIR)/kernel/ke/cpuid.o: $(KALEIDDIR)/kernel/ke/cpuid.c \ @rm -f $@.1 $@.2 @echo ${CL2}[$@] ${CL}Compiled.${CL3} +$(KOBJDIR)/kernel/ke/shcmds.o: $(KALEIDDIR)/kernel/sh/shcmds.c | $(KOBJDIR) + @mkdir -p $(shell dirname $@) + @$(KCC_MATHS) -MM -MT $(@:%.d=%.o) -MF $@ $< + @echo ${CL2}[$@] ${CL}Compiled.${CL3} + $(KOBJDIR)/kernel/mm/paging.o: $(KALEIDDIR)/kernel/mm/paging.c \ $(KALEIDDIR)/kernel/mm/paging.asm | $(KOBJDIR) @mkdir -p $(shell dirname $@) diff --git a/include/io/spkr.h b/include/io/spkr.h index 815b4a6..760928a 100644 --- a/include/io/spkr.h +++ b/include/io/spkr.h @@ -32,7 +32,6 @@ //----------------------------------------------------------------------------// void IoStartSpeaker(int); -void IoQuietSpeaker(void); void IoDoBeep(void); void IoDoTone(uint tone, uint time); void IoDoBeepNoIdt(void); diff --git a/kaleid/kernel/io/spkr.c b/kaleid/kernel/io/spkr.c index 95ca317..53d25aa 100644 --- a/kaleid/kernel/io/spkr.c +++ b/kaleid/kernel/io/spkr.c @@ -24,6 +24,7 @@ #include #include +#include extern bool KeIdtIsInitialized; @@ -44,7 +45,7 @@ void IoStartSpeaker(int freq) KeRestoreIRQs(flags); } -void IoQuietSpeaker(void) +static inline void IoQuietSpeaker(void) { ulong flags = KePauseIRQs(); IoWriteByteOnPort(0x61, IoReadByteFromPort(0x61) & 0xFC); @@ -54,8 +55,7 @@ void IoQuietSpeaker(void) void IoDoTone(uint tone, uint time) { IoStartSpeaker(tone); - KeDelayExecution(time); - IoQuietSpeaker(); + KeSleep(time); } static void IoDoToneNoIdt(uint tone, uint time) @@ -79,8 +79,6 @@ void IoDoBeepNoIdt(void) void IoDoStarWars(void) { - size_t i; - struct Note { uint tone; uint time; @@ -91,7 +89,6 @@ void IoDoStarWars(void) {523, 60}, {87, 100}, {440, 200}, {110, 200}, {349, 140}, {87, 100}, {523, 60}, {87, 100}, {440, 200}, {110, 200}, {440, 200}, {110, 200}, - {659, 200}, {110, 200}, {659, 200}, {110, 200}, {659, 200}, {87, 200}, {698, 140}, {87, 100}, {523, 60}, {87, 100}, {415, 200}, {87, 200}, @@ -99,7 +96,14 @@ void IoDoStarWars(void) {440, 200}, {110, 200}, {110, 200}, {110, 200} }; - for (i = 0; i < sizeof(score)/sizeof(struct Note); i++) { + //bprintf(BStdOut, "\n"); + + for (uint i = 0; i < sizeof(score)/sizeof(struct Note); i++) { IoDoTone(score[i].tone, score[i].time); + //bprintf(BStdOut, "%d ", i); + //BStdOut->flusher(BStdOut); } + IoQuietSpeaker(); + + //bprintf(BStdOut, "FINISHED\n"); } diff --git a/kaleid/kernel/sh/shcmds.c b/kaleid/kernel/sh/shcmds.c index e664dc5..93b2718 100644 --- a/kaleid/kernel/sh/shcmds.c +++ b/kaleid/kernel/sh/shcmds.c @@ -164,6 +164,28 @@ error_t CmdDumpATASect(int argc, char **argv, char *cmdline) return EOK; } +error_t CmdFloat(int argc, char **argv, char *cmdline) +{ + double param = (double)ShAtoi(argv[1]); + + double b = 138899.009 / (14.9); //9322,0811409 + + double b_ent = (double)(ulong)b; + double dec = 0.0; + + KernLog("int(b) = %d \n", (ulong)b_ent); + KernLog("dec(b) = "); + + for(double i = 0; i < param; i++) { + dec = (((b*param) - (b_ent*param)) * 10.0 * i / param); + KernLog("%d", (ulong)dec); + } + + KernLog("\n"); + + return EOK; +} + error_t CmdHelp(int argc, char **argv, char *cmdline) { uint i, count = 0; @@ -338,8 +360,9 @@ static Command_t testcmdtable[] = { "args", CmdArgs, "Print command line" }, { "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" }, { "help", CmdHelpTest, "Show this message" }, - { "pfault", CmdPF, "Provoke a PF. Usage: pfault
"}, - { "pstest", CmdPsTest, "Scheduler test routine" }, + { "pf", CmdPF, "Provoke a PF. Usage: pfault
"}, + { "ps", CmdPsTest, "Scheduler test routine" }, + { "float", CmdFloat, "Float test" }, { "rpag", CmdReloadPage, "Reload the pages directory" }, { "shell", CmdShell, "Start a new shell (nested)", }, { "stkov", CmdStackOverflow, "Provoke a stack overflow" },