/* Generated by CMunge 0.76 (10 May 2006) [with GCCSDK 4 changes r7662 at
 * /trunk/gcc4/riscos/cmunge]
 * CMunge Copyright (c) 1999-2006 Robin Watts/Justin Fletcher
 * Copyright (c) 2007-2014 GCCSDK Developers and contributors */

#ifndef _CMUNGE_MIDISupport_H_
#define _CMUNGE_MIDISupport_H_

#include "kernel.h"

#define CMUNGE_VERSION (76)
#define CMHG_VERSION   (531) /* Nearest equivalent version */

#define Module_Title		"MIDISupport"
#define Module_Help		"MIDISupport"
#define Module_VersionString	"0.06"
#define Module_VersionNumber	6
#ifndef Module_Date
#define Module_Date		"02 Nov 2025"
#endif

#ifdef __cplusplus
extern "C" {
#endif


/***************************************************************************
 * Function:     module_init
 * Description:  Initialise the module, setting up vectors, callbacks and
 *               any other parts of the system necessary for the module to
 *               function.
 * Parameters:   tail        = pointer to command line (control terminated)
 *               podule_base = address of podule module was started from, or
 *                             NULL if none
 *               pw          = private word for module
 * On exit:      Return NULL for successful initialisation, or a pointer to
 *               an error block if the module could not start properly.
 **************************************************************************/
_kernel_oserror *module_init(const char *tail, int podule_base, void *pw);


/***************************************************************************
 * Function:     module_term
 * Description:  Finalise the module, shutting down any systems necessary,
 *               freeing vectors and releasing workspace
 * Parameters:   fatal       = fatality indicator; 1 if fatal, 0 if
 *                             reinitialising
 *               podule_base = address of podule module was started from, or
 *                             NULL if none
 *               pw          = private word for module
 * On exit:      Return NULL for successful finalisation, or a pointer to an
 *               error block if module was not shutdown properly.
 **************************************************************************/
_kernel_oserror *module_term(int fatal, int podule_base, void *pw);


/***************************************************************************
 * Description:  Star command and help request handler routines.
 * Parameters:   arg_string = pointer to argument string (control
 *                            terminated), or output buffer
 *               argc       = number of arguments passed
 *               number     = command number (see CMD_* definitions below)
 *               pw         = private word for module
 * On exit:      If number indicates a help entry:
 *                 To output, assemble zero terminated output into
 *                 arg_string, and return help_PRINT_BUFFER to print it.
 *                 To stay silent, return NULL.
 *                 To given an error, return an error pointer.
 *                 [In this case, you need to cast the 'const' away]
 *               If number indicates a configure option:
 *                 If arg_string is arg_STATUS, then print status, otherwise
 *                 use argc and arg_string to set option.
 *                 Return NULL for no error.
 *                 Return one of the four error codes below (configure_*)
 *                 for a generic error message.
 *                 Return an error pointer for a custom error.
 *               If number indicates a command entry:
 *                 Execute the command given by number, and arg_string.
 *                 Return NULL on success,
 *                 Return a pointer to an error block on failure.
 **************************************************************************/
_kernel_oserror *module_command(const char *arg_string, int argc,
                                int number, void *pw);
#define help_PRINT_BUFFER		((_kernel_oserror *) arg_string)
#define arg_CONFIGURE_SYNTAX		((char *) 0)
#define arg_STATUS			((char *) 1)
#define configure_BAD_OPTION		((_kernel_oserror *) -1)
#define configure_NUMBER_NEEDED		((_kernel_oserror *) 1)
#define configure_TOO_LARGE		((_kernel_oserror *) 2)
#define configure_TOO_MANY_PARAMS	((_kernel_oserror *) 3)

/* Command numbers, as passed to the command handler functions (see above) */
#undef CMD_MIDIMap
#define CMD_MIDIMap (0)
#undef CMD_MIDIConnect
#define CMD_MIDIConnect (1)
#undef CMD_MIDIDisconnect
#define CMD_MIDIDisconnect (2)
#undef CMD_MidiSdebug
#define CMD_MidiSdebug (3)


/***************************************************************************
 * Description:  SWI handler routine. All SWIs for this module will be
 *               passed to these routines.
 * Parameters:   number = SWI number within SWI chunk (i.e. 0 to 63)
 *               r      = pointer to register block on entry
 *               pw     = private word for module
 * On exit:      Return NULL if SWI handled sucessfully, setting return
 *               register values (r0-r9) in r.
 *               Return error_BAD_SWI for out of range SWIs.
 *               Return an error block for a custom error.
 **************************************************************************/
/* Function called to handle SWI calls */
_kernel_oserror *module_swi(int number, _kernel_swi_regs *r, void *pw);
/* SWI number definitions */
#define MIDISupport_00 (0x0004ee80)
#undef MIDISupport_InstallDriver
#undef XMIDISupport_InstallDriver
#define MIDISupport_InstallDriver  (0x0004ee80)
#define XMIDISupport_InstallDriver (0x0006ee80)
#undef MIDISupport_RemoveDriver
#undef XMIDISupport_RemoveDriver
#define MIDISupport_RemoveDriver  (0x0004ee81)
#define XMIDISupport_RemoveDriver (0x0006ee81)
#undef MIDISupport_DriverInfo
#undef XMIDISupport_DriverInfo
#define MIDISupport_DriverInfo    (0x0004ee82)
#define XMIDISupport_DriverInfo   (0x0006ee82)
#undef MIDISupport_CreateDriver
#undef XMIDISupport_CreateDriver
#define MIDISupport_CreateDriver  (0x0004ee83)
#define XMIDISupport_CreateDriver (0x0006ee83)
#undef MIDISupport_Send
#undef XMIDISupport_Send
#define MIDISupport_Send          (0x0004ee84)
#define XMIDISupport_Send         (0x0006ee84)
#undef MIDISupport_Receive
#undef XMIDISupport_Receive
#define MIDISupport_Receive       (0x0004ee85)
#define XMIDISupport_Receive      (0x0006ee85)
#undef MIDISupport_Connect
#undef XMIDISupport_Connect
#define MIDISupport_Connect       (0x0004ee86)
#define XMIDISupport_Connect      (0x0006ee86)
#undef MIDISupport_ConnectName
#undef XMIDISupport_ConnectName
#define MIDISupport_ConnectName   (0x0004ee87)
#define XMIDISupport_ConnectName  (0x0006ee87)
#undef MIDISupport_GetAddress
#undef XMIDISupport_GetAddress
#define MIDISupport_GetAddress    (0x0004ee88)
#define XMIDISupport_GetAddress   (0x0006ee88)
#undef MIDISupport_Insert
#undef XMIDISupport_Insert
#define MIDISupport_Insert        (0x0004ee89)
#define XMIDISupport_Insert       (0x0006ee89)

/* Special error for 'SWI values out of range for this module' */
#define error_BAD_SWI ((_kernel_oserror *) -1)


/***************************************************************************
 * Function:     midis_receive
 * Description:  Symbol for entry point to module - NOT a C function.
 *               This name should be used as an argument to
 *               OS_Claim/OS_Release as required, but should never be called
 *               from C.
 **************************************************************************/
extern void midis_receive(void);


/***************************************************************************
 * Function:     midis_receive_handler
 * Description:  Generic handler function
 * Parameters:   r  = pointer to register block on entry
 *               pw = private word for module
 * On exit:      Update r to alter return values
 *               Return NULL to return with V clear
 *               Return an error pointer to set V and r0
 **************************************************************************/
_kernel_oserror *midis_receive_handler(_kernel_swi_regs *r, void *pw);


/***************************************************************************
 * Function:     midis_givedata
 * Description:  Symbol for entry point to module - NOT a C function.
 *               This name should be used as an argument to
 *               OS_Claim/OS_Release as required, but should never be called
 *               from C.
 **************************************************************************/
extern void midis_givedata(void);


/***************************************************************************
 * Function:     midis_givedata_handler
 * Description:  Generic handler function
 * Parameters:   r  = pointer to register block on entry
 *               pw = private word for module
 * On exit:      Update r to alter return values
 *               Return NULL to return with V clear
 *               Return an error pointer to set V and r0
 **************************************************************************/
_kernel_oserror *midis_givedata_handler(_kernel_swi_regs *r, void *pw);

/* Error base for this module */
#define ERROR_BASE (0x000001e6)

#ifdef __cplusplus
}
#endif

#endif
