English 中文(简体)
NASM accessing sound card directly (No OS)
原标题:

I m attempting to write a very simple OS in ASM and C. (NASM assembler) I would like to access the sound card directly, with or without drivers. If I don t need drivers, how could I access and send a sample audio file to the sound card? (An example would be nice) If I do need drivers, is there anyway to interface them and call functions from the drivers? And how do I access and send a sample audio file to the sound card? (Another example would be nice)

问题回答

I hate to discourage you, but modern sound card drivers are extremely complicated, and as you probably know, OS-specific. This is one of the difficult challenges in OS development - driver support. It s not something that can be achieved with a simple code snippet.

In order to load a file, you need a file system. Have you implemented that yet? The fact that you used the "kernel" flag suggests that your OS is still in its infancy. I m not sure I would want to put sound support into the kernel of an operating system.

That being said, there is a good emulator called Bochs that has Sound Blaster 16 emulation. And some really old documentation for how to program it. This might be your best bet. Accessing sound hardware was much easier back in the day.

Your best bet is probably to look at either the Linux or FreeBSD sound drivers and see what they do. You re not likely to get much better implementation documentation for any but the simplest sound card...

This is a hard problem. Be warned :-p

Of course you need a driver, and of course there s no easy way to interface with existing ones (there was some proposal for a unified OS-agnostic "Uniform Driver Interface" - but I don t think it got anywhere).

So, after you ve written the code to read a file from your hard drive, you ll need to roll your own audio driver.

Now, I haven t done this in a while, so this may be outdated, but in the 90 s you d configure your sound card with a few out dx, al (details varied across soundcards), and then setup DMA to send data from a memory buffer to your card. The card (or was it the DMA controller?) would fire off an interrupt when it reached the end of the buffer, which you d use to fill the buffer with new data.

If your card has a working linux driver I d start by looking at its code. Otherwise, you ll have to reverse engineer the windows driver, Soft-Ice s bpio (break on io port access) logging used to be good for that iirc.

Good luck.

Here is a free open-sourced operating system written in all assembly. It is great reference for assembly kernel programming if you are new to it.

http://www.menuetos.net/index.htm





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签