Sound Blaster Driver

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
User avatar
Jeko
Member
Member
Posts: 500
Joined: Fri Mar 17, 2006 12:00 am
Location: Napoli, Italy

Sound Blaster Driver

Post by Jeko »

I've tried to implement sound blaster driver, but this code doesn't work. Could you help me? Where is the error?

Code: Select all

#define NO_CHIP	0x00
#define BASE0	0x200
#define BASE1	0x220
#define BASE2	0x240
#define BASE3	0x260
#define BASE4	0x280
#define BASE5	0x210

#define DSP_RESET		0x06
#define DSP_READ_DATA_PORT	0x0A

unsigned short int check_dsp()
{
	unsigned short int val[] =
		{ BASE0, BASE1, BASE2, BASE3, BASE4, BASE5, NO_CHIP };
	static short int count = sizeof(val) / sizeof(*val) - 1;	// don't test no_chip
	unsigned short int i = 0;

	// for each possible port
	for (i = 0; i < count; i++) {
		// test it by attempting to reset the DSP
		if (reset_dsp(val[i]))
			// if found, break now
			break;
	}

	// base io address, or, if not found, NO_CHIP, since i=countS
	return val[i];
}

unsigned short int reset_dsp(const unsigned short int base)
{
	int loopc;
	outportb(base + DSP_RESET, 1);
	udelay();
	outportb(base + DSP_RESET, 0);
	udelay();
	udelay();
	udelay();

	for (loopc = 0; loopc < 1000 && !(inportb(base + DSP_READ_BUFFER_STATUS) & 0x80); loopc++);	/* Wait for data
													 * available status */

	if (inportb(base + DSP_READ_DATA_PORT) != 0xAA)
		return 0;
	return 1;
}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Standard reply: Have you tried using bochs' debugging features?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply