/*
 * coRoutine.h
 *
 * [Generated from coRoutine, 25 September 1996]
 */

#if !defined(__CC_NORCROFT) || !defined(__arm)
  #error You must use the Norcroft ARM Compiler for Sapphire programs
#endif

#pragma include_only_once
#pragma force_top_level

#ifndef __coRoutine_h
#define __coRoutine_h

#ifndef __sapphire_h
  #include "sapphire.h"
#endif

/*----- Overview ----------------------------------------------------------*
 *
 * Functions provided:
 *
 *  coRout_create
 *  coRout_switch
 *  coRout_destroy
 *  coRout_end
 */

/* --- coRout_create --- *
 *
 * On entry:	R0 == pointer to coroutine
 *		R1 == R10 value to pass to coroutine
 *		R2 == R12 value to pass to coroutine
 *		R3 == size of stack to pass (0 for default)
 *
 * On exit:	R0 == coroutine handle
 *		May return an error
 *
 * Use:		Creates a new coroutine.  It may be given control using
 *		coRout_switch.  Its registers are on entry:
 *
 *		R0 == its coroutine handle
 *		R10 == value passed to coRout_create in R1
 *		R12 == value passed to coRout_create in R2
 *		R13 == pointer to the stack created for it
 */

extern routine coRout_create;

/* --- coRout_switch --- *
 *
 * On entry:	R0 == coroutine to switch to, or 0 for main
 *
 * On exit:	--
 *
 * Use:		Switches context to another coroutine.
 */

extern routine coRout_switch;

/* --- coRout_destroy --- *
 *
 * On entry:	R0 == coroutine handle to destroy
 *
 * On exit:	--
 *
 * Use:		Destroys a coroutine.
 */

extern routine coRout_destroy;

/* --- coRout_end --- *
 *
 * On entry:	--
 *
 * On exit:	Doesn't.
 *
 * Use:		Terminates the current coroutine.
 */

extern routine coRout_end;

/*----- That's all, folks -------------------------------------------------*/

#endif
