/*

    Copyright (C) Corollary, Inc., 1993, 1994.
    All Rights Reserved.
    This Module contains Proprietary Information of
    Corollary, Inc., and should be treated as Confidential.

Module Name:

    cbus_sw.c

Abstract:

    This module defines the switch table for various C-bus platform
    architectures under OS/2 2.x.  During initialization, the
    Corollary PSD will revector all hardware-specific actions
    through the switch table declared here.

Author:

    Landy Wang (landy@corollary.com) 11-Jan-1994
 */

#include "cbustype.h"
#include "cbusrrd.h"		/* PSD <-> RRD interface definitions */
#include "cbus_sw.h"		/* C-bus OS/2-specific implementation stuff */

extern VOID		Cbus2RequestSoftwareInterrupt (IN ULONG, IN ULONG);
extern VOID		Cbus2BootCPU (ULONG, ULONG);
extern VOID		Cbus2InitializePlatform ( VOID);
extern VOID		Cbus2InitializeCPU ( ULONG);
extern BOOL		Cbus2EnableInterrupt(IN ULONG, IN ULONG);
extern VOID		Cbus2DisableInterrupt(ULONG, ULONG);
extern VOID		Cbus2ParseRRD(IN PEXT_ID_INFO, IN OUT PULONG);
extern ULONG		Cbus2ResolveNMI(VOID);
extern VOID		Cbus2ResetAllOtherProcessors(ULONG);
extern ULONG		Cbus2EnablePIC(ULONG);
extern ULONG		Cbus2GetMasks(VOID);
extern ULONG		Cbus2GetIRR(VOID);
extern ULONG		Cbus2GetISR(VOID);
extern BOOL		Cbus2ReachIOPic(VOID);

extern VOID		Cbus1RequestSoftwareInterrupt ( IN ULONG, IN ULONG );
extern VOID		Cbus1BootCPU ( IN ULONG, IN ULONG);
extern VOID		Cbus1InitializePlatform ( VOID);
extern VOID		Cbus1InitializeCPU ( ULONG);
extern BOOL		Cbus1EnableInterrupt(IN ULONG, IN ULONG);
extern VOID		Cbus1DisableInterrupt(ULONG, ULONG);
extern VOID		Cbus1ParseRRD(IN PEXT_ID_INFO, IN OUT PULONG);
extern ULONG		Cbus1ResolveNMI(VOID);
extern VOID		Cbus1ResetAllOtherProcessors(ULONG);
extern ULONG		Cbus1EnablePIC(ULONG);
extern ULONG		Cbus1GetMasks(VOID);
extern ULONG		Cbus1GetIRR(VOID);
extern ULONG		Cbus1GetISR(VOID);
extern BOOL		Cbus1ReachIOPic(VOID);

CBUS_PSDSW cbus2_table = {
	Cbus2RequestSoftwareInterrupt,
	Cbus2BootCPU,
	Cbus2InitializePlatform,
	Cbus2InitializeCPU,

	Cbus2EnableInterrupt,
	Cbus2DisableInterrupt,
	Cbus2ParseRRD,
	Cbus2ResolveNMI,

	Cbus2ResetAllOtherProcessors,
	Cbus2EnablePIC,
	Cbus2GetMasks,
	Cbus2GetIRR,

	Cbus2GetISR,
	Cbus2ReachIOPic
};

CBUS_PSDSW cbus1_table = {
	Cbus1RequestSoftwareInterrupt,
	Cbus1BootCPU,
	Cbus1InitializePlatform,
	Cbus1InitializeCPU,

	Cbus1EnableInterrupt,
	Cbus1DisableInterrupt,
	Cbus1ParseRRD,
	Cbus1ResolveNMI,

	Cbus1ResetAllOtherProcessors,
	Cbus1EnablePIC,
	Cbus1GetMasks,
	Cbus1GetIRR,

	Cbus1GetISR,
	Cbus1ReachIOPic
};

PCBUS_PSDSW	CbusBackend;

BOOL
CbusMPMachine(VOID)
/*

    Routine Description:
    
    recognize which type of C-bus multiprocessor system it is:

	    C-bus I Symmetric XM
	    C-bus II:
	    
    Use CbusGlobal to determine which type of machine this is.
    note the ordering of the platform recognition is important for future
    expansion.

Return Value:

    TRUE if this Corollary MP machine is supported by this MP PSD.
    FALSE if not.

 */
{
	ULONG machine;

	machine = CbusGlobal.machine_type;

	if (machine & MACHINE_CBUS2) {

		CbusBackend = &cbus2_table;

	}
	else if (machine & MACHINE_CBUS1_XM) {

		CbusBackend = &cbus1_table;

	}
	else {
		return FALSE;
	}

	return TRUE;
}
