I have created a C++ micro Kernel for a school project. I used vmware on a Suse Laptop. . Last year, i used the same laptop on a Suse distrib and the speaker worked fine.
And now The kernel works but not the pc speaker ( I have just the same bip for each note)
Any Idea ?
Code: Select all
Speaker::Speaker()
{
initialize = false;
init();
}
Speaker::~Speaker()
{
initialize = true;
close();
}
void Speaker::close()
{
if(initialize)
{
outb(0x61, inb(0x61) & 252); // close speaker
initialize = false;
}
}
void Speaker::init()
{
if(!initialize)
{
listUsed = false;
outb(0x61, inb(0x61) | 3); // enable speaker
outb(0x43, 0xb6); // program the pit
initialize = true;
}
}
void Speaker::playMarseillaise()
{
init();
asm("cli");
int counter = (0x1234DD / RE); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(800);
counter = (0x1234DD / RE); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(800);
counter = (0x1234DD / SOL); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(1000);
counter = (0x1234DD / SOL); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(800);
counter = (0x1234DD / LA); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(800);
counter = (0x1234DD / LA); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(800);
counter = (0x1234DD / 587); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(1000);
counter = (0x1234DD / SI); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(400);
counter = (0x1234DD / SOL); // calculate frequency
outb(0x42, counter & 0xff); // LSB
outb(0x42, counter >> 8); // MSB
wait(800);
__asm("cli");
close();
}