.DOS device drivers
-
- Member
- Posts: 83
- Joined: Fri Oct 22, 2004 11:00 pm
.DOS device drivers
Anybody here know a good tutorials of how to make dos device drivers in assembly? Or information about how standard dos device drivers work?
Anything is possible if you put your mind to it.
ComputerPsi
ComputerPsi
-
- Member
- Posts: 83
- Joined: Fri Oct 22, 2004 11:00 pm
Theres not many examples, but what you do is set up a int, say int 40h
Here is a sound driver example
The above examle works like this, if you want to use sound function from your program, you would call int 40h and then test eax for 0xffffffff and if there print "error no sound card load etc.
But lets say i have made a soundcard with lots of function, how do i link it ?.
Simple by having another function that all drives can call, that replace the address "Sound" with the start of my functions, a function like this
Now in the driver you would do this when loading it
Now to use the sound driver from program, you would do something like this
That it i have kept it simple for this demo, but you would need a bit of error checking etc.
NOTE: There may be typo errors in the code and its based a 32bit pmode OS, as in a dos like OS.
PS: Here a good basic asm dos driver for AC97 sound card
http://www.programmersheaven.com/downlo ... nload.aspx
Here is a sound driver example
Code: Select all
Int_40h:
pushad
push es
push ds
;-----------------
call [CallTableSound]
jc Int_40hError
;-----------------
pop ds
pop es
popad
iret
Int_40hError:
pop ds
pop es
popad
mov eax,0xffffffff
iret
sound:
stc
ret
CallTable:
CallTable0 dd 0
CallTableSound dd Sound
But lets say i have made a soundcard with lots of function, how do i link it ?.
Simple by having another function that all drives can call, that replace the address "Sound" with the start of my functions, a function like this
Code: Select all
Int_41h:
pushad
push es
push ds
;-----------------
mov edi,CallTable
shl ecx,2 ; ecx = number for driver eg: as sound is first it will have number 1
add edi,ecx ;ecx now = 4
movsd ; note esi = the drive function start address
;-----------------
pop ds
pop es
popad
iret
Code: Select all
start:
mov ecx,1
mov esi,SoundDriverStart
int 41h
; more code here etc
SoundDriverStart:
cmp eax, 0
je soundOn
cmp eax,1
je soundOff
;and so on
Code: Select all
int 40h
cmp eax,0xffffffff
je ToPrintError
mov eax,0 ;this will turn sound on
int 40h
;and more code here
NOTE: There may be typo errors in the code and its based a 32bit pmode OS, as in a dos like OS.
PS: Here a good basic asm dos driver for AC97 sound card
http://www.programmersheaven.com/downlo ... nload.aspx
-
- Member
- Posts: 83
- Joined: Fri Oct 22, 2004 11:00 pm
- chase
- Site Admin
- Posts: 710
- Joined: Wed Oct 20, 2004 10:46 pm
- Libera.chat IRC: chase_osdev
- Location: Texas
- Discord: chase/matt.heimer
- Contact:
There really isn't much of a driver framework like I think your expecting. The basic idea is you create a TSR and you make up the rest, usually you take over an interrupt vector. You should be able to find example mouse drivers but lots of hardware didn't have a driver. Programs still did direct hardware access back then. Thats why having things like a sound blaster compatible sound card and vesa video card were so important.ComputerPsi wrote:I guess I need to give more details as this is going a little off subject. The main reason I want to do that is to figure out how some *.dos drivers work.
Dos does actually does have a structured driver interface; it just seems widely ignored by most people since it's only required by the devices defined in IO.SYS, or if you want your driver to support the IOCTL-related int 0x21 sub-functions. I'd doubt it was ever used for anything other than storage devices, though. I've implemented a slightly modified form of it in my psuedo dos clone to implement my devices and vfs drivers.
It's not likely the .dos file you're interested in uses it.
It's not likely the .dos file you're interested in uses it.