2007-11-23 12:30:50 +01:00
|
|
|
#ifndef AUDIO_FW_H
|
|
|
|
#define AUDIO_FW_H
|
|
|
|
|
2010-03-22 22:25:22 +01:00
|
|
|
#include <minix/drivers.h>
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
#include <minix/chardriver.h>
|
2007-11-23 12:30:50 +01:00
|
|
|
#include <sys/ioc_sound.h>
|
|
|
|
|
|
|
|
|
2012-03-24 16:16:34 +01:00
|
|
|
int drv_init(void);
|
|
|
|
int drv_init_hw(void);
|
|
|
|
int drv_reset(void);
|
|
|
|
int drv_start(int sub_dev, int DmaMode);
|
|
|
|
int drv_stop(int sub_dev);
|
|
|
|
int drv_set_dma(u32_t dma, u32_t length, int chan);
|
|
|
|
int drv_reenable_int(int chan);
|
|
|
|
int drv_int_sum(void);
|
|
|
|
int drv_int(int sub_dev);
|
|
|
|
int drv_pause(int chan);
|
|
|
|
int drv_resume(int chan);
|
2013-09-03 01:59:20 +02:00
|
|
|
int drv_io_ctl(unsigned long request, void * val, int * len, int sub_dev);
|
2012-03-24 16:16:34 +01:00
|
|
|
int drv_get_irq(char *irq);
|
|
|
|
int drv_get_frag_size(u32_t *frag_size, int sub_dev);
|
2007-11-23 12:30:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* runtime status fields */
|
|
|
|
typedef struct {
|
|
|
|
int readable;
|
|
|
|
int writable;
|
|
|
|
int DmaSize;
|
|
|
|
int NrOfDmaFragments;
|
|
|
|
int MinFragmentSize;
|
|
|
|
int NrOfExtraBuffers;
|
|
|
|
int Nr; /* sub device number */
|
|
|
|
int Opened; /* sub device opened */
|
|
|
|
int DmaBusy; /* is dma busy? */
|
|
|
|
int DmaMode; /* DEV_WRITE / DEV_READ */
|
|
|
|
int DmaReadNext; /* current dma buffer */
|
|
|
|
int DmaFillNext; /* next dma buffer to fill */
|
|
|
|
int DmaLength;
|
|
|
|
int BufReadNext; /* start of extra circular buffer */
|
|
|
|
int BufFillNext; /* end of extra circular buffer */
|
|
|
|
int BufLength;
|
|
|
|
int RevivePending; /* process waiting for this dev? */
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
endpoint_t ReviveProcNr; /* the process to unblock */
|
2013-09-03 01:59:20 +02:00
|
|
|
cdev_id_t ReviveId; /* request ID */
|
2007-11-23 12:40:33 +01:00
|
|
|
cp_grant_id_t ReviveGrant; /* grant id associated with io */
|
Server/driver protocols: no longer allow third-party copies.
Before safecopies, the IO_ENDPT and DL_ENDPT message fields were needed
to know which actual process to copy data from/to, as that process may
not always be the caller. Now that we have full safecopy support, these
fields have become useless for that purpose: the owner of the grant is
*always* the caller. Allowing the caller to supply another endpoint is
in fact dangerous, because the callee may then end up using a grant
from a third party. One could call this a variant of the confused
deputy problem.
From now on, safecopy calls should always use the caller's endpoint as
grant owner. This fully obsoletes the DL_ENDPT field in the
inet/ethernet protocol. IO_ENDPT has other uses besides identifying the
grant owner though. This patch renames IO_ENDPT to USER_ENDPT, not only
because that is a more fitting name (it should never be used for I/O
after all), but also in order to intentionally break any old system
source code outside the base system. If this patch breaks your code,
fixing it is fairly simple:
- DL_ENDPT should be replaced with m_source;
- IO_ENDPT should be replaced with m_source when used for safecopies;
- IO_ENDPT should be replaced with USER_ENDPT for any other use, e.g.
when setting REP_ENDPT, matching requests in CANCEL calls, getting
DEV_SELECT flags, and retrieving of the real user process's endpoint
in DEV_OPEN.
The changes in this patch are binary backward compatible.
2011-04-11 19:35:05 +02:00
|
|
|
endpoint_t SourceProcNr; /* process to send notify to (FS) */
|
2007-11-23 12:30:50 +01:00
|
|
|
u32_t FragSize; /* dma fragment size */
|
|
|
|
char *DmaBuf; /* the dma buffer; extra space for
|
|
|
|
page alignment */
|
|
|
|
phys_bytes DmaPhys; /* physical address of dma buffer */
|
|
|
|
char* DmaPtr; /* pointer to aligned dma buffer */
|
|
|
|
int OutOfData; /* all buffers empty? */
|
|
|
|
char *ExtraBuf; /* don't use extra buffer;just
|
|
|
|
declare a pointer to supress
|
|
|
|
error messages */
|
|
|
|
} sub_dev_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int minor_dev_nr;
|
|
|
|
int read_chan;
|
|
|
|
int write_chan;
|
|
|
|
int io_ctl;
|
|
|
|
} special_file_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char* DriverName;
|
|
|
|
int NrOfSubDevices;
|
|
|
|
int NrOfSpecialFiles;
|
|
|
|
} drv_t;
|
|
|
|
|
|
|
|
EXTERN drv_t drv;
|
|
|
|
EXTERN sub_dev_t sub_dev[];
|
|
|
|
EXTERN special_file_t special_file[];
|
|
|
|
|
|
|
|
/* Number of bytes you can DMA before hitting a 64K boundary: */
|
|
|
|
#define dma_bytes_left(phys) \
|
|
|
|
((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
|
|
|
|
|
|
|
|
#define NO_CHANNEL -1
|
|
|
|
|
|
|
|
#define NO_DMA 0
|
2013-09-03 01:59:20 +02:00
|
|
|
#define READ_DMA 1
|
|
|
|
#define WRITE_DMA 2
|
2007-11-23 12:30:50 +01:00
|
|
|
|
|
|
|
#endif /* AUDIO_FW_H */
|