flat assembler
Message board for the users of flat assembler.
Index
> Linux > OSS ioctl parameters |
Author |
|
revolution 11 Mar 2013, 00:49
There should not be any need to guess. It should be possible to determine exactly what the __SIOWR macro does by reading the definition of it.
|
|||
11 Mar 2013, 00:49 |
|
keantoken 11 Mar 2013, 04:17
OH.
Code: /* #define SIOCTYPE (0xff<<8) */ 74 #define SIOCPARM_MASK 0x1fff /* parameters must be < 8192 bytes */ 75 #define SIOC_VOID 0x00000000 /* no parameters */ 76 #define SIOC_OUT 0x20000000 /* copy out parameters */ 77 #define SIOC_IN 0x40000000 /* copy in parameters */ 78 #define SIOC_INOUT (SIOC_IN|SIOC_OUT) 79 80 #define __SIO(x,y) ((int)(SIOC_VOID|(x<<8)|y)) 81 #define __SIOR(x,y,t) ((int)(SIOC_OUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 82 #define __SIOW(x,y,t) ((int)(SIOC_IN|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 83 #define __SIOWR(x,y,t) ((int)(SIOC_INOUT|((sizeof(t)&SIOCPARM_MASK)<<16)|(x<<8)|y)) 84 #define __SIOC_SIZE(x) ((x>>16)&SIOCPARM_MASK) 85 #define __SIOC_DIR(x) (x & 0xf0000000) 86 #define __SIOC_NONE SIOC_VOID 87 #define __SIOC_READ SIOC_OUT 88 #define __SIOC_WRITE SIOC_IN 89 # endif /* _IOWR */ 90 #endif /* !__SIOWR */ So __SIOWR seems to be equivalent to: Code: ioctl_mask dq (0x20000000 or 0x40000000 or ((0x1fff and 4) shl 16)) or ('P' shl 8) or 5 So now I've changed it to Code: ; Set bit format lea rdx,[bitmask_afmt] mov rsi,[ioctl_mask] mov rdi,[dev_fd] mov rax,sys_ioctl syscall or rax,rax js ERRFMT segment readable writeable ; data bitmask_afmt dq 0x00001000 ioctl_mask dq (0x20000000 or 0x40000000 or ((0x1fff and 4) shl 16)) or ('P' shl 8) or 5 Now it's telling me that the 3rd argument points to an invalid memory address. It's possible something in ioctl_mask is still wrong, since changing things in it does not lead to an EINVAL. |
|||
11 Mar 2013, 04:17 |
|
bitRAKE 11 Mar 2013, 07:51
Maybe, this is a dumb* question: Is __SIOWR a memory address or a value to be used by the syscall? Maybe, I'm understanding incorrectly, but aren't all the arguments unsigned ints? Why would the syscall be needed if you were reading directly from the hardware?
*I don't have a clue about Linux. |
|||
11 Mar 2013, 07:51 |
|
keantoken 11 Mar 2013, 18:19
For OSS you use SYS_OPEN to open /dev/dsp. You use SYS_IOCTL to set parameters such as format and samplerate. You write to the file to play, read from the file to record. OSS handles everything else.
I'm not sure how to know whether a parameter is a memory address or the actual parameter. I'm guessing that's what it means when it says the parameter is a "pointer". But a pointer in Assembly is its own thing, so a pointer in this sense would in fact be a pointer to a pointer! |
|||
11 Mar 2013, 18:19 |
|
bitRAKE 21 Mar 2013, 04:06
A pointer in assembly is just a number/address. It's how one uses that number that matters.
mov eax,[0x80000000] ...same as... mov eax,0x80000000 ; just a number mov eax,[eax] So, I assume the brackets are not needed in your code? |
|||
21 Mar 2013, 04:06 |
|
keantoken 21 Mar 2013, 08:24
I really have tried everything I know of and the best error I can get is Invalid Argument. This happens when I use either the lea instruction or remove the brackets. So it seems the arguments must be addresses (pointers), rather than actual input. Assuming this is right, then my input must be wrong. But i've replicated the soundcard.h code to generate the input in assembly. The errno numbers just aren't enough to know what I'm doing wrong.
|
|||
21 Mar 2013, 08:24 |
|
keantoken 21 Mar 2013, 09:16
I managed to compile this C program:
http://manuals.opensound.com/developer/singen.c.html I am trying to work with the debuggers I have but I haven't been able to figure out how to display the syscall parameters in any of them. BUT, if and when I do, maybe it will tell me what I'm doing wrong. Note: this program plays a sine wave at full blast!
|
|||||||||||
21 Mar 2013, 09:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.