Where's Konstantin?
Tried to send this to "konst linuxassembly org" but got it bounced back. I saw a reference a while back in this list for another address for him, but wasn't able to see it. Anyone know how to reach Konstantin... or what the story is with asmutils?
TIA,
Frank
-----------------------------------
Hello Konstantin,
I just tried to build asmutils-0.17, and it wants me to roll back to Nasm 0.98. No way in hell! Much too buggy! Rolled back to asmutils-0.14 instead.
What's the problem with 0.17 that Nasm won't build it? Or, put another way, what's the problem with Nasm that it won't build 0.17 (builds 0.14 fine, so I'm inclined to think it's "not a Nasm problem"... but I always think that :)
Sorry to have been so slow attempting to upgrade to asmutils-0.17 - hate to see this situation continue!
Best,
Frank
OSS ioctls...
I am going to go insane... Please help...
Here's my code:
section .text
%define SNDCTL_DSP_RESET 0x5000
%define SNDCTL_DSP_SPEED 0x5002
%define SNDCTL_DSP_SETFMT 0x5005
%define SNDCTL_DSP_GETFMTS 0x500B
%define SNDCTL_DSP_CHANNELS 0x5006
%define SNDCTL_DSP_POST 0x5008
%define SNDCTL_DSP_SETFRAGMENT 0x500A
%define AFMT_S16_LE 0x0010
sys sys_open, dev_dsp, O_WRONLY; systrap "opening /dev/dsp" mov [out_desc], eax
sys sys_ioctl, [out_desc], SNDCTL_DSP_RESET, 0; systrap
"resetting dsp"
sys sys_ioctl, [out_desc], SNDCTL_DSP_GETFMTS, formats; systrap
"getting dsp formats"
sys sys_ioctl, [out_desc], SNDCTL_DSP_CHANNELS, channels; systrap
"setting dsp channels"
sys sys_ioctl, [out_desc], SNDCTL_DSP_SPEED, speed; systrap
"setting dsp speed"
sys sys_ioctl, [out_desc], SNDCTL_DSP_SETFMT, format; systrap
"setting dsp format"
sys sys_ioctl, [out_desc], SNDCTL_DSP_SETFRAGMENT, fragment; systrap
"setting dsp fragment size"
section .data
channels dd 1
speed dd 8000
format dd AFMT_S16_LE
formats dd 0
fragment dd $00080006
ass dd 0
section .bss
out_desc resd 1
Every time I run it I get a error message like this:
Error getting dsp formats
EAX Error Code: EINVAL -- Invalid argument
EAX: FFFFFFEA EBX: 00000004 ECX: 0000500B EDX: 0804B3A0 ESI: 00000000 EDI: 00000000 EBP: 00000000 ESP: BFFFF810 EIP: 0804822E EFLAGS: 00000000 00000000 00000010 00000010
I really can't imagine what the invalid argument is. According to the register dump right there the file descriptor is in ebx, the ioctl number in ecx, and a memory pointer in edx, yet every ioctl except for SNDCTL_DSP_RESET gives that same error.
If I forget the ioctls and go on, I can write to the sound device and get sound, but I need to use them because it's not set to the right format by default.
I've run strace on sox and I'm using the same ioctls it does, yet they work for it and not for me. This is nuts.
The OSS documentation says not to use SNDCTL_DSP_RESET after opening. I've tried it without it and with it (since sox does it) and it's the same either way.
The only thing I could think might be wrong is that the ioctl numbers are wrong, but I looked in soundcard.h and it says SNDCTL_DSP_GETFMTS is ('P',
11) which best I can figure has to be $500B.
Re: OSS ioctls...
Quoted 32 lines · Richard Cooper
I am going to go insane... Please help...
Here's my code:
section .text %define SNDCTL_DSP_RESET 0x5000 %define SNDCTL_DSP_SPEED 0x5002 %define SNDCTL_DSP_SETFMT 0x5005 %define SNDCTL_DSP_GETFMTS 0x500B %define SNDCTL_DSP_CHANNELS 0x5006 %define SNDCTL_DSP_POST 0x5008 %define SNDCTL_DSP_SETFRAGMENT 0x500A %define AFMT_S16_LE 0x0010 sys sys_open, dev_dsp, O_WRONLY; systrap "opening /dev/dsp" mov [out_desc], eax sys sys_ioctl, [out_desc], SNDCTL_DSP_RESET, 0; systrap"resetting dsp"
syssys_ioctl, [out_desc],SNDCTL_DSP_GETFMTS, formats; systrap
"getting dsp formats"
syssys_ioctl, [out_desc],SNDCTL_DSP_CHANNELS, channels; systrap
"setting dsp channels"
syssys_ioctl, [out_desc],SNDCTL_DSP_SPEED, speed; systrap
"setting dsp speed"
syssys_ioctl, [out_desc],SNDCTL_DSP_SETFMT, format; systrap
"setting dsp format"
syssys_ioctl, [out_desc],SNDCTL_DSP_SETFRAGMENT, fragment; systrap
"setting dsp fragment size"
Quoted 9 lines
section .data
channels dd 1
speed dd 8000
format ddAFMT_S16_LE
formats dd 0
fragment dd $00080006
ass dd 0
[cut]
Correct me if i'm wrong but as i remember the ioctl gets an int (dd) as an argument - not an address. So [] is needed.
Signature · 1 line
Maciej Hrebien
Re: OSS ioctls...
Quoted 44 lines · Maciej Hrebien
Quoted 32 lines · Richard Cooper
I am going to go insane... Please help...
Here's my code:
section .text %define SNDCTL_DSP_RESET 0x5000 %define SNDCTL_DSP_SPEED 0x5002 %define SNDCTL_DSP_SETFMT 0x5005 %define SNDCTL_DSP_GETFMTS 0x500B %define SNDCTL_DSP_CHANNELS 0x5006 %define SNDCTL_DSP_POST 0x5008 %define SNDCTL_DSP_SETFRAGMENT 0x500A %define AFMT_S16_LE 0x0010 sys sys_open, dev_dsp, O_WRONLY; systrap "opening /dev/dsp" mov [out_desc], eax sys sys_ioctl, [out_desc], SNDCTL_DSP_RESET, 0; systrap"resetting dsp"
syssys_ioctl, [out_desc],SNDCTL_DSP_GETFMTS, formats; systrap
"getting dsp formats"
syssys_ioctl, [out_desc],SNDCTL_DSP_CHANNELS, channels; systrap
"setting dsp channels"
syssys_ioctl, [out_desc],SNDCTL_DSP_SPEED, speed; systrap
"setting dsp speed"
syssys_ioctl, [out_desc],SNDCTL_DSP_SETFMT, format; systrap
"setting dsp format"
syssys_ioctl, [out_desc],SNDCTL_DSP_SETFRAGMENT, fragment; systrap
"setting dsp fragment size"Quoted 9 lines
section .data
channels dd 1
speed dd 8000
format ddAFMT_S16_LE
formats dd 0
fragment dd $00080006
ass dd 0
Quoted 4 lines
[cut]
Correct me if i'm wrong but as i remember the ioctl gets an int (dd) as an argument - not an address. So [] is needed.
What am i talking about? sorry! Did you tried the linuxassembly.org/articles/audio.html? Your code looks very similar and %define's seems to be different.
Signature · 1 line
Maciej Hrebien
Re: OSS ioctls...
Quoted 2 lines
Did you tried the linuxassembly.org/articles/audio.html? Your code looks very similar and %define's seems to be different.
I must have skimmed throught the list too fast, I didn't realize there was an article. Otherwise I would have read that instead of the massive PDF than is the OSS documentation. It's really quite nice documentation. It just naturally doesn't define the IOCTL numbers. It's at
http://www.opensound.com/pguide/oss.pdf if anyone's interested.
But anyway, looking at the example I see there's a $C0040000 or'ed with most of the ioctl numbers, and adding that to my numbers fixed everything up.
Looking back at the header file I see that some of the IOCTL numbers go through a different macro...
#define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int)
#define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y))
#define SIOC_INOUT (SIOC_IN|SIOC_OUT)
#define SIOC_OUT 0x20000000 /* copy out parameters */
#define SIOC_IN 0x40000000 /* copy in parameters */Now as I see it, that should make those IOCTL numbers begin with $6004, not $C004, but $6004 doesn't work, only $C004 works. So I still don't see where the $C004 is coming from, but at least I know how to make it work now.
Thanks for your help. I probably wouldn't have figured that out on my own until next year or the year after when I happen to stumble upon the linuxassembly article, seeing as the header file isn't even correct.
Re: OSS ioctls...
Quoted 23 lines · Richard Cooper
Quoted 3 lines
Did you tried the linuxassembly.org/articles/audio.html? Your code looks very similar and %define's seems to be different.
I must have skimmed throught the list too fast, I didn't realize there was an article. Otherwise I would have read that instead of the massive PDF than is the OSS documentation. It's really quite nice documentation. It just naturally doesn't define the IOCTL numbers. It's at
http://www.opensound.com/pguide/oss.pdf if anyone's interested.But anyway, looking at the example I see there's a $C0040000 or'ed with most of the ioctl numbers, and adding that to my numbers fixed everything up.
Looking back at the header file I see that some of the IOCTL numbers go through a different macro...
#define SNDCTL_DSP_SETFRAGMENT _SIOWR('P',10, int) #define _SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) #define SIOC_INOUT (SIOC_IN|SIOC_OUT) #define SIOC_OUT 0x20000000 /* copy out parameters */ #define SIOC_IN 0x40000000 /* copy in parameters */
Quoted 8 lines
Now as I see it, that should make those IOCTL numbers begin with $6004, not $C004, but $6004 doesn't work, only $C004 works. So I still don't see where the $C004 is coming from, but at least I know how to make it work now.
Thanks for your help. I probably wouldn't have figured that out on my own until next year or the year after when I happen to stumble upon the linuxassembly article, seeing as the header file isn't even correct.
Read soundcard.h more careful. soundcard.h includes <linux/ioctl.h> which includes <asm/ioctl.h> with defined _IOWR. So the code we are considering is not even preprocesed. "#if defined(_IOWR)..." from soundcard.h does "#define _SIOWR _IOWR". _IOWR from <asm/ioctl.h> takes three arguments with first one named 'type' and 'dir' eq _IOC_READ|_IOC_WRITE when going to _IOC(dir,type,nr,size). As _IOC_READ|_IOC_WRITE is numericaly eq 3 and 'dir' from _IOC is shifted left 30 times (_IOC_DIRSHIFT) so you have 0xc in the MSB.
Hope this helps :)
Signature · 1 line
Maciej Hrebien
Re: OSS ioctls...
In reply to Richard CooperQuoted 4 lines · Richard Cooper
The only thing I could think might be wrong is that the ioctl numbers are wrong, but I looked in
soundcard.hand it saysSNDCTL_DSP_GETFMTSis ('P',
11) which best I can figure has to be $500B.
OK, i have had time to check it... SNDCTL_DSP_GETFMTS is eq to _SIOR('P',11,int) which evaluates to:
((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) where x='P', y=11, t=int
Look soundcard.h for more details. Hope this helps and sorry for 3 posts -
somethimes it happens ;)
Signature · 1 line
Maciej Hrebien
Quoted 3 lines
Tried to send this to "konst linuxassembly org" but got it bounced back. I saw a reference a while back in this list for another address for him, but wasn't able to see it.
The address you're referring to was <[email protected]>
b