From 927aeb0872d723a92362c607df3d0d898873044b Mon Sep 17 00:00:00 2001 From: Curle Date: Mon, 19 Aug 2019 23:51:15 +0100 Subject: [PATCH] Fix an implicit function declaration --- kernel/bootstrap.c | 93 +++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/kernel/bootstrap.c b/kernel/bootstrap.c index 7592c83..91cb59d 100644 --- a/kernel/bootstrap.c +++ b/kernel/bootstrap.c @@ -36,6 +36,53 @@ __attribute__((aligned(64))) static IDT_GATE IDTData[256] = {0}; __attribute__((aligned(4096))) static size_t FirstPageTable[512] = {0}; +/* + * 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); +} + + /* Main system handover from UEFI. * Prepares the processor, the screen, and memory. */ void PrepareSystem(FILELOADER_PARAMS* FLOP) { @@ -111,52 +158,6 @@ 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. */