Seriously prioritise output.

Added a beep function to allow PC Speaker output.
This will require an edit to the current QEMU launchscript to get working.
This commit is contained in:
Curle 2019-08-19 22:58:26 +01:00
parent 437e10e86c
commit 2691c1e30e

View File

@ -52,6 +52,8 @@ void PrepareSystem(FILELOADER_PARAMS* FLOP) {
InstallGDT(); InstallGDT();
InstallIDT(); InstallIDT();
beep();
if(SetIdentityMap(FLOP->RTServices) == NULL) { if(SetIdentityMap(FLOP->RTServices) == NULL) {
Memory_Info.MemoryMap = FLOP->MemoryMap; Memory_Info.MemoryMap = FLOP->MemoryMap;
} }
@ -108,6 +110,54 @@ void PrepareSystem(FILELOADER_PARAMS* FLOP) {
} }
/*
* Following section is taken from the OSDev Wiki page on PC Speaker.
* This is beeped first, before *anything* else.
* This way, we know that at least *something* works.
*/
//Play sound using built in speaker
static void play_sound(uint32_t nFrequence) {
uint32_t Div;
uint8_t tmp;
//Set the PIT to the desired frequency
Div = 1193180 / nFrequence;
WritePort(0x0043, 0xb6, 1);
WritePort(0x0042, (uint8_t) (Div), 1);
WritePort(0x0042, (uint8_t) (Div >> 8), 1);
//And play the sound using the PC speaker
tmp = ReadPort(0x0061, 1);
if (tmp != (tmp | 3)) {
WritePort(0x0061, tmp | 3, 1);
}
}
//make it shutup
static void nosound() {
uint8_t tmp = ReadPort(0x0061, 1) & 0xFC;
WritePort(0x0061, tmp, 1);
}
//Make a beep
void beep() {
play_sound(1000);
timer_wait(10);
nosound();
//set_PIT_2(old_frequency);
}
void timer_wait(int ticks){
uint64_t FinalTick = time + ticks;
while(time < FinalTick);
}
/* A temporary system for keeping track of system performance. */ /* A temporary system for keeping track of system performance. */
size_t ClockTick() { size_t ClockTick() {