This commit is contained in:
Julian Barathieu 2019-05-06 21:08:16 +02:00
parent c55c45f1f9
commit 6e295c23e3
7 changed files with 135 additions and 19 deletions

View File

@ -94,7 +94,8 @@ KernSources = libbuf/buf.c libbuf/bputc.c libbuf/bscroll.c \
kernel/mm/heap.c kernel/mm/malloc.c \ kernel/mm/heap.c kernel/mm/malloc.c \
kernel/mm/gdt.c kernel/ps/sched.c \ kernel/mm/gdt.c kernel/ps/sched.c \
kernel/init/info.c kernel/init/ssp.c \ kernel/init/info.c kernel/init/ssp.c \
kernel/io/rtc.c kernel/io/keyb.c kernel/io/rtc.c kernel/io/keyb.c \
kernel/io/spkr.c
LibCObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(LibCSources)) LibCObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(LibCSources))
@ -156,20 +157,20 @@ $(KOBJDIR)/%.o: %.c $(INCLUDEDIR)/*/*.h | $(KOBJDIR)
@echo ${CL2}[$@] ${CL}Compiled.${CL3} @echo ${CL2}[$@] ${CL}Compiled.${CL3}
test: all test: all
@qemu-system-x86_64 -rtc base=localtime -m 4G -hda $(BUILDDIR)/bin/disk.img \ @qemu-system-x86_64 -rtc base=localtime -m 4G -hda $(BUILDDIR)/bin/disk.img -soundhw pcspk \
-d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log & -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
test32: all test32: all
@qemu-system-i386 -hda $(BUILDDIR)/bin/disk.img -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log & @qemu-system-i386 -hda $(BUILDDIR)/bin/disk.img -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
debug: all debug: all
@qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot \ @qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot -soundhw pcspk \
-no-shutdown -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log & -no-shutdown -d cpu_reset,guest_errors,pcall,int 2> $(BUILDDIR)/qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > $(BUILDDIR)/kaleid64_disasm.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > $(BUILDDIR)/kaleid64_disasm.asm
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > $(BUILDDIR)/kaleid32_disasm.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > $(BUILDDIR)/kaleid32_disasm.asm
gdb: all gdb: all
@qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot \ @qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot -soundhw pcspk \
-no-shutdown -d cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log & -no-shutdown -d cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > kaleid64_disasm.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > kaleid64_disasm.asm
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > kaleid32_disasm.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > kaleid32_disasm.asm
@ -180,7 +181,7 @@ gdb: all
-ex "break BtStartKern" \ -ex "break BtStartKern" \
ddd: all ddd: all
@qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot \ @qemu-system-x86_64 -m 64M -hda $(BUILDDIR)/bin/disk.img -no-reboot -soundhw pcspk \
-no-shutdown -d cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log & -no-shutdown -d cpu_reset,guest_errors,pcall,int -s -S 2> $(BUILDDIR)/qemu.log &
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > kaleid64_disasm.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 64 > kaleid64_disasm.asm
@ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > kaleid32_disasm.asm @ndisasm $(BINDIR)/kaleid -o 0x00100000 -b 32 > kaleid32_disasm.asm

View File

@ -101,19 +101,19 @@ struct Processor_t
}; };
struct ISRFrame_t { struct ISRFrame_t {
/* the register file */ /* The register file */
ulong regs[15]; ulong regs[15];
/* the error code and interrupt id */ /* The error code and interrupt id */
ulong intNo; ulong intNo;
ulong ErrorCode; ulong ErrorCode;
/* these are pushed automatically by the CPU */ /* These are pushed automatically by the CPU */
ulong rip; ulong rip;
ulong cs; ulong cs;
ulong rflags; ulong rflags;
ulong rsp; ulong rsp;
ulong ss; ulong ss;
} __attribute__((__packed__)); } __attribute__((__packed__));

41
include/kernel/speaker.h Normal file
View File

@ -0,0 +1,41 @@
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Desc: Speaker functions //
// //
// //
// Copyright © 2018-2019 The OS/K Team //
// //
// This file is part of OS/K. //
// //
// OS/K is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// any later version. //
// //
// OS/K is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#ifndef _KALKERN_BASE_H
#include <kernel/base.h>
#endif
#ifndef _KALKERN_SPEAKER_H
#define _KALKERN_SPEAKER_H
//----------------------------------------------------------------------------//
void IoStartSpeaker(int freq);
void IoQuietSpeaker(void);
void IoDoBeep(void);
//----------------------------------------------------------------------------//
#endif

View File

@ -22,6 +22,15 @@
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. // // along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//
#ifndef _KALKERN_BASE_H
#include <kernel/base.h>
#endif
#ifndef _KALKERN_TIME_H
#define _KALKERN_TIME_H
//----------------------------------------------------------------------------//
typedef struct typedef struct
{ {
uchar sec; uchar sec;
@ -42,3 +51,7 @@ extern Time_t* IoGetRtcTime(void);
extern char* IoGetRtcTimeChar(void); extern char* IoGetRtcTimeChar(void);
//static char* WeekDays[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; //static char* WeekDays[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
//----------------------------------------------------------------------------//
#endif

View File

@ -29,6 +29,7 @@
#include <kernel/heap.h> #include <kernel/heap.h>
#include <kernel/mm.h> #include <kernel/mm.h>
#include <kernel/time.h> #include <kernel/time.h>
#include <kernel/speaker.h>
// info.c // info.c
extern void BtDoSanityChecks(uint mbMagic); extern void BtDoSanityChecks(uint mbMagic);
@ -94,7 +95,9 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
/* i++; */ /* i++; */
/* } */ /* } */
KernLog("Goodbye at %s", IoGetRtcTimeChar()); KernLog("Goodbye at %s\n", IoGetRtcTimeChar());
IoDoBeep();
// End this machine's suffering // End this machine's suffering
BStdOut->flusher(BStdOut); BStdOut->flusher(BStdOut);

60
kaleid/kernel/io/spkr.c Normal file
View File

@ -0,0 +1,60 @@
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Desc: Speaker functions //
// //
// //
// Copyright © 2018-2019 The OS/K Team //
// //
// This file is part of OS/K. //
// //
// OS/K is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// any later version. //
// //
// OS/K is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY//without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with OS/K. If not, see <https://www.gnu.org/licenses/>. //
//----------------------------------------------------------------------------//
#include <kernel/speaker.h>
#include <kernel/iomisc.h>
#include <kernel/time.h>
void IoStartSpeaker(int freq)
{
char temp;
int pitf = 1193180 / freq;
IoWriteByteOnPort(0x43, 0xB6);
IoWriteByteOnPort(0x42, (char)pitf);
IoWriteByteOnPort(0x42, (char)(pitf >> 8));
temp = IoReadByteFromPort(0x61);
if (temp != (temp | 3)) {
IoWriteByteOnPort(0x61, temp | 3);
}
}
void IoQuietSpeaker(void)
{
IoWriteByteOnPort(0x61, IoReadByteFromPort(0x61) & 0xFC);
}
void IoDoBeep(void)
{
IoStartSpeaker(1000);
// Worst possible way of waiting
// We need actual timers
ulong ticks = IoGetRtcTicks();
while (IoGetRtcTicks() < ticks + 512);
IoQuietSpeaker();
}

View File

@ -372,8 +372,6 @@ void PrintList(ListHead_t *head)
void pstest(void) void pstest(void)
{ {
//ClearTerm(StdOut);
KernLog("\nTime Critical: "); KernLog("\nTime Critical: ");
PrintList(TimeCritProcs); PrintList(TimeCritProcs);