/* 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_SerialMidi_H_
#define _CMUNGE_SerialMidi_H_

#include "kernel.h"

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

#define Module_Title		"SerialMidi"
#define Module_Help		"SerialMidi"
#define Module_VersionString	"0.02"
#define Module_VersionNumber	2
#ifndef Module_Date
#define Module_Date		"04 Jan 2024"
#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_call
 * 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_call(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_SerialMidi
#define CMD_SerialMidi (0)


/***************************************************************************
 * 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:     upcall_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 upcall_callback(void);


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


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


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


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


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


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


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


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


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


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


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


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


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


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


/***************************************************************************
 * Function:     upcallv_handler
 * Description:  Vector handler function
 * Parameters:   r  = pointer to register block on entry
 *               pw = private word for module
 * On exit:      Update r to alter return values
 *               Return VECTOR_CLAIM to claim (return via stack)
 *               Return VECTOR_PASSON to pass on (return via r14)
 **************************************************************************/
int upcallv_handler(_kernel_swi_regs *r, void *pw);

/* VECTOR_PASSON can be returned from vectors to pass the call on to other
 * handlers. */
#define VECTOR_PASSON (1)
/* VECTOR_CLAIM can be returned from vectors to claim the vector and return
 * with the updated register block. */
#define VECTOR_CLAIM (0)

#ifdef __cplusplus
}
#endif

#endif
