SB16 Protected Mode?

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
Squrky

SB16 Protected Mode?

Post by Squrky »

Hi,

Has anyone successfully programmed a SB16 card to output wav or midi (protected mode)? I'm writing a small OS for use in a music studio and I just can't get my SB16 to do anything. I'm using gcc and nasm.

I think I've found my card correctly (actually an SBLive Value) using the pci bios, but don't know what to do next. Anyone? :)
Adek336

RE:SB16 Protected Mode?

Post by Adek336 »

I've got a rmode program which ran under a DOS box in windows will emit random noises. I suppose it uses a SB16 emulator created for the dos boxes.

Unfortunately, I didn't use to comment experimental code :( and it is written in a rarely used language Sphinx C--. I hope you get a way to compile it:

word SB_port = 0x220; // so this is were sb16 sits?

// do nothing until a keypress
byte wait_key()
{
  AH = 0;
  $ INT 0x16
}

//out a byte
void outportb(word port, byte data)
{
  AL = data;
  DX = port;
  $ OUT DX, AL
}

// in a byte
byte inportb(word port)
{
  DX = port;
  $ IN AL, DX
}

//write to the sb16
void writeDSP(byte data)
{
  while (inportb(SB_port + 0xE) > 127) readDSP();
  outportb(SB_port + 0xC, data);
}

//read from the sb16
byte readDSP()
{
  while (inportb(SB_port + 0xE) < 128) ;
  inportb(SB_port + 0xA);
}

//main
int main()
byte buffer[16];
{
  outportb(SB_port + 6, 1); CX = 256; loop (CX) { $ NOP } ;
  outportb(SB_port + 6, 0);

  writeDSP(0xD1);

// setup DMA
  outportb(0x0A, 0x05);
  outportb(0x0C, 0x00);
  outportb(0x0B, 0x49);
  outportb(0x02, 0x00);
  outportb(0x02, 0x00);
  outportb(0x83, 0x00);
  outportb(0x03, 0xFF);
  outportb(0x03, 0xFF);
  outportb(0x0A, 0x01);
// end setup DMA

  writeDSP(0x40);
  writeDSP(171);

  writeDSP(0x14);

  writeDSP(0xFE);writeDSP(0xFF);

  wait_key();
}
Squrky

RE:SB16 Protected Mode?

Post by Squrky »

Thanks for your input Adek336, but I think my problem is much more inherent to the way I'm setting up my kernel (protected mode). My actual procedure goes something like this:

1) Initialise GDT
2) Initialise IDT
3) Program PIC
4) Initialise keyboard.
5) Detect BIOS32 Services
6) Use BIOS32 to find PCI BIOS.

Then for my SoundBlaster...

7) Get PCI address of my SBLive.
8) Query base address registers of sb card to get I/O port address(es).

Its at this point that I get confused. BAR0 of my SBLive (first device) reads 0x0000e000 (from memory). That presumably means I/O 0xe000. So I use this as the base port address for my sound blaster routines (like the ones in the previous post), but my card doesn't respond AT ALL.

I know this is a bit long-winded but someone must have gone through this to program an SB16 compatible. Am I way off the mark? Do I have to perhaps write the BARs back to 'wake' the card up?

I'm stuck. Help, anyone... :)

Thanks.
tom1000000

RE:SB16 Protected Mode?

Post by tom1000000 »

You know there is the Linux source code. I know its not always easy to understand but you may have no other choices.
Post Reply