solo_interface.h 3.35 KB
/*
 * Copyright (C) 1996-1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * 
 * This file is part of the SimOS distribution. 
 * See LICENSE file for terms of the license. 
 *
 */

/*****************************************************************
 * solo_interface.h
 * 
 * This is the interface between an application and solo mipsy. 
 *****************************************************************/

#ifndef _SOLO_INTERFACE_H_
#define _SOLO_INTERFACE_H_

/*
 * All backdoor calls will go through this structure
 */
typedef void (*Func)(void) ;


typedef struct CommArea {
   void (*SetupCommArea)(void);

   void (*Create)( void (*func)() );
   void (*Exit)(void);
   int  (*GetCPUNum)(void);
   int  (*ActiveProcs)(void);
   void (*ResetStats)(void);
   int  (*Flush)(void *);
   void (*Sync)(void);
   void (*TurnOnCaches)(void);
   void (*TurnOffCaches)(void);
   unsigned long long (*CurrentTime)(void);
   void (*IOMap)(unsigned, long long);
   void (*IOMapGeneral)(unsigned, int details, long long);
   void (*PlaceRange)(unsigned start, unsigned stop, int node);
   void (*WaitForEnd)(int);
   
   /* Fake synchronization calls */
   void *(*LockInit)(void);
   int  (*Lock)(void *);
   void (*Unlock)(void *);
   void (*BarEnter)(void);
   void (*BarExit)(void);

#ifdef FLASHPOINT
  void (*FP_Malloc)(int, unsigned, void *, char *);
  
  unsigned long long (*FP_Virtual_To_Physical)(unsigned long long);
  
  unsigned (*FP_GetNumCpus)(void);

#endif

   void *libcStart;
} CommArea;

#define IN_MIPSY        51071;      /* Code returned by a syscall to
                                       say that I'm in Mipsy. */
#define COMM_LENGTH     0x00004000

/* This start point (also defined in the SOLO Makefile work fine, but don't
allow enough space for big runs
#define COMM_START      0x50000000 
*/

/* These start points leave an additional 256MB of space for address-hungry
flashlite runs of 64 procs and up.. */
#define COMM_START      0x40000000

#define MIPSY_COMM_ADDR COMM_START

#define SOLO_STACK_SIZE (1024 * 1024)

#ifndef T5_MODEL
#define SOLO_STACK_TOP  COMM_START
#else
#define SOLO_STACK_TOP  0x1600000
				/* I load the stack down low for T5-model runs,
				   since I need to pack everything close
				   together since I hand-code the TLB entries */
#endif

#define CommAreaPtr     ((CommArea *) MIPSY_COMM_ADDR)

#ifndef SOLO_CACHE_LINE_SIZE
#define SOLO_CACHE_LINE_SIZE 256    /* Maximum cache line size supported */
#endif 

#define IO_MAP_UNCACHED 	0x80000000
#define IO_MAP_ACCELERATED 	0x40000000

/* Any routines that are linked within the application (inside the
   macros) need to be defined here so that the app will link */

extern void *LibcStart(void);

extern unsigned long long _LoadDouble(unsigned long long *);
extern void _StoreDouble(unsigned long long *, unsigned long long);
extern void _Sync(void);
extern void _Prefetch(void *);
extern void _PrefetchX(void *);
extern void _SoloLockEnter(unsigned int *);
extern void _SoloUnlock(unsigned int *);
extern void _SoloBarrier(void *, int);
extern void _SoloExit(void);
extern int  _CheckPlatform(void);
extern void SoloIOMapGeneral(unsigned va, int details, long long pa);
extern int _FetchAndStore(void *addr, int value);
extern int _CompareAndSwap(void *, int oldval, int newval);

typedef struct MCSnode {
   struct MCSnode *next;
   volatile int locked;
} MCSnode;

typedef MCSnode *MCSlock;

#endif