/* 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_MIDISynth_H_
#define _CMUNGE_MIDISynth_H_

#include "kernel.h"

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

#define Module_Title		"MIDISynth"
#define Module_Help		"MIDISynth"
#define Module_VersionString	"0.26"
#define Module_VersionNumber	26
#ifndef Module_Date
#define Module_Date		"25 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);


/***************************************************************************
 * Function:     service_midi
 * Description:  Service call handler routine. All services which are being
 *               received by the module will be passed to this routine.
 * Parameters:   service = service call number
 *               r       = pointer to register block on entry
 *               pw      = private word for module
 * On exit:      Update register values on return by updating r.
 **************************************************************************/
void service_midi(int service, _kernel_swi_regs *r, 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_MidiSynth
#define CMD_MidiSynth (0)


/***************************************************************************
 * 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 MIDISynth_00 (0x000ca340)
#undef MIDISynth_Control
#undef XMIDISynth_Control
#define MIDISynth_Control         (0x000ca340)
#define XMIDISynth_Control        (0x000ea340)
#undef MIDISynth_Edit
#undef XMIDISynth_Edit
#define MIDISynth_Edit            (0x000ca341)
#define XMIDISynth_Edit           (0x000ea341)
#undef MIDISynth_Note
#undef XMIDISynth_Note
#define MIDISynth_Note            (0x000ca342)
#define XMIDISynth_Note           (0x000ea342)

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


/***************************************************************************
 * Function:     service_callback
 * 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 service_callback(void);


/***************************************************************************
 * Function:     service_callback_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 *service_callback_handler(_kernel_swi_regs *r, void *pw);


/***************************************************************************
 * Function:     timer_callback
 * 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 timer_callback(void);


/***************************************************************************
 * Function:     timer_callback_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 *timer_callback_handler(_kernel_swi_regs *r, void *pw);


/***************************************************************************
 * Function:     driver_info
 * 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 driver_info(void);


/***************************************************************************
 * Function:     driver_info_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 *driver_info_handler(_kernel_swi_regs *r, void *pw);


/***************************************************************************
 * Function:     driver_init
 * 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 driver_init(void);


/***************************************************************************
 * Function:     driver_init_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 *driver_init_handler(_kernel_swi_regs *r, void *pw);


/***************************************************************************
 * Function:     driver_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 driver_receive(void);


/***************************************************************************
 * Function:     driver_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 *driver_receive_handler(_kernel_swi_regs *r, void *pw);

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

#ifdef __cplusplus
}
#endif

#endif
