minix/drivers/audio/common/audio_fw.h
Cristiano Giuffrida 48c6bb79f4 Driver refactory for live update and crash recovery.
SYSLIB CHANGES:
- DS calls to publish / retrieve labels consider endpoints instead of u32_t.

VFS CHANGES:
- mapdriver() only adds an entry in the dmap table in VFS.
- dev_up() is only executed upon reception of a driver up event.

INET CHANGES:
- INET no longer searches for existing drivers instances at startup.
- A newtwork driver is (re)initialized upon reception of a driver up event.
- Networking startup is now race-free by design. No need to waste 5 seconds
at startup any more.

DRIVER CHANGES:
- Every driver publishes driver up events when starting for the first time or
in case of restart when recovery actions must be taken in the upper layers.
- Driver up events are published by drivers through DS. 
- For regular drivers, VFS is normally the only subscriber, but not necessarily.
For instance, when the filter driver is in use, it must subscribe to driver
up events to initiate recovery.
- For network drivers, inet is the only subscriber for now.
- Every VFS driver is statically linked with libdriver, every network driver
is statically linked with libnetdriver.

DRIVER LIBRARIES CHANGES:
- Libdriver is extended to provide generic receive() and ds_publish() interfaces
for VFS drivers.
- driver_receive() is a wrapper for sef_receive() also used in driver_task()
to discard spurious messages that were meant to be delivered to a previous
version of the driver.
- driver_receive_mq() is the same as driver_receive() but integrates support
for queued messages.
- driver_announce() publishes a driver up event for VFS drivers and marks
the driver as initialized and expecting a DEV_OPEN message.
- Libnetdriver is introduced to provide similar receive() and ds_publish()
interfaces for network drivers (netdriver_announce() and netdriver_receive()).
- Network drivers all support live update with no state transfer now.

KERNEL CHANGES:
- Added kernel call statectl for state management. Used by driver_announce() to
unblock eventual callers sendrecing to the driver.
2010-04-08 13:41:35 +00:00

105 lines
3.3 KiB
C

#ifndef AUDIO_FW_H
#define AUDIO_FW_H
#include <minix/drivers.h>
#include <minix/driver.h>
#include <sys/ioc_sound.h>
/* change to DEBUG to 1 to print debug info and error messages */
#define DEBUG 0
#if DEBUG
#define dprint printf
#else
#define dprint (void)
#endif
#define error printf
_PROTOTYPE( void main, (void) );
_PROTOTYPE( int drv_init, (void) );
_PROTOTYPE( int drv_init_hw, (void) );
_PROTOTYPE( int drv_reset, (void) );
_PROTOTYPE( int drv_start, (int sub_dev, int DmaMode) );
_PROTOTYPE( int drv_stop, (int sub_dev) );
_PROTOTYPE( int drv_set_dma, (u32_t dma, u32_t length, int chan) );
_PROTOTYPE( int drv_reenable_int, (int chan) );
_PROTOTYPE( int drv_int_sum, (void) );
_PROTOTYPE( int drv_int, (int sub_dev) );
_PROTOTYPE( int drv_pause, (int chan) );
_PROTOTYPE( int drv_resume, (int chan) );
_PROTOTYPE( int drv_io_ctl, (int request, void * val, int * len, int sub_dev) );
_PROTOTYPE( int drv_get_irq, (char *irq) );
_PROTOTYPE( int drv_get_frag_size, (u32_t *frag_size, int sub_dev) );
/* 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? */
int ReviveStatus; /* return val when proc unblocked */
int ReviveProcNr; /* the process to unblock */
cp_grant_id_t ReviveGrant; /* grant id associated with io */
void *UserBuf; /* address of user's data buffer */
int ReadyToRevive; /* are we ready to revive process?*/
int NotifyProcNr; /* process to send notify to (FS) */
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 TRUE 1
#define FALSE 0
#define NO_DMA 0
#endif /* AUDIO_FW_H */