vmWare and pc speaker

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jeandaniel
Posts: 14
Joined: Wed Nov 14, 2007 3:26 pm
Location: Paris, France

vmWare and pc speaker

Post by jeandaniel »

Hello,
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();
}

User avatar
alethiophile
Member
Member
Posts: 90
Joined: Sat May 30, 2009 10:28 am

Re: vmWare and pc speaker

Post by alethiophile »

Well, this can't be right:

Code: Select all

   init();
   asm("cli");
   (lots of code)
   __asm("cli");
   close();
Shouldn't the second one be 'sti'? And why do you use asm for one, and __asm for the other?
If I had an OS, there would be a link here.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: vmWare and pc speaker

Post by earlz »

What does your wait function look like? does it include a STI and CLI?
Post Reply