simmagic.h
5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* 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.
*
*/
/*****************************************************************
* simmagic.h
*
* Interface between the OS view of the machine and the SimOS
* device simulators.
*
* Created by: John Chapin, 05/95
* Revision history:
* 06/95 (Dan Teodosiu) added interrupt subsystem support.
* 06/95 (John Chapin) added register access, interrupt event codes
* 06/95 (John Chapin) moved flash defines out, added universal I/O ops
* 11/95 (John Chapin) added PPC version 2 support
* 07/96 (Dan Teodosiu) complete OS/SimOS overhaul
* 02/97 (Ben Werther) generalized number of devices per machine
*
****************************************************************/
#ifndef _SIM_MAGIC_H
#define _SIM_MAGIC_H
/* Interval (in simulated cycles) for polling input devs */
#define MAGIC_POLL_INTERVAL 100000
#ifdef TORNADO
/*
* tornado runs mipsy. (bugnion)
*/
#undef MAGIC_POLL_INTERVAL
#define MAGIC_POLL_INTERVAL 10000
#endif
/* This function initializes:
* - all MAGIC's (PPR's, PPC's, etc.)
* - all BDOOR device registers
* - all devices and device interrupt handlers
* - device polling
*/
extern void sim_magic_init(int restoreFromChkpt);
/* Access types: given a virtual KSEG1 address, Mipsy wants to know
* the kind of access performed.
*/
typedef enum {
SIMMAGIC_DIRECT, /* processed by sim_magic.c */
SIMMAGIC_UNCACHED, /* Flashlite: regular uncached access */
SIMMAGIC_UNCACHED_ACCELERATED /* Flashlite: uncached accelerated access */
} SimMagic_accesstype;
/* Determine kind of access based on VA.
* NOTE: we now squeeze the T5 64bit address space into a 32bit one.
* See the "SimOS to FLASH Physical Address Mapping" doc.
*/
extern SimMagic_accesstype SimMagic_kseg1_accesstype(uint VA);
/* Get an OSPC line into the specified buffer.
* This is called by Mipsy from CacheCmdDone (see the comment in that
* routine and in simmagic.c) so that OSPC gets can be emulated. The
* routine returns a delay which is 0 if this OSPC access should not
* stall, or otherwise the maximum number of ticks for which the
* access should be stalled. Note that CacheCmdUnstall may be called
* later (when the OSPC access becomes available) to allow the access
* to complete.
*
* NOTE: this routine is a nop if Flashlite is used or if the
* requested address doesn't correspond to a valid OSPC offset.
*/
extern int sim_magic_OSPC_access(int cpuNum, /* CPU making the access */
uint VA, /* accessed VA */
byte *data /* data buffer for OSPC data */
);
/* Called by mem system to inform simmagic that an OSPC access has
* stalled or timed out. This controls whether an interrupt is
* generated or not when the SIPS arrives.
*/
extern void sim_magic_OSPC_stalled(int cpuNum, /* CPU number */
VA va, /* VA for OSPC access */
int stalled /* stalled or not? */
);
/* Function type for functions called by the simulator when fielding
* a ref to the backdoor. If the function returns != 0, then the
* requested access is illegal and should be bus-errored.
*/
typedef int (*MagicFunction)(int cpuNum, /* CPU making this access */
uint VA, /* accessed virtual address */
int type, /* access type */
void* buff); /* buff width acc to type */
/* Checkpointing support */
extern void sim_magic_cpt(int restoreFromChkpt);
/* called when checkpointing, so that timeLeft field can be updated. */
extern void TimerUpdateTimeLeft(void);
/* called when restoring from a checkpoint */
extern void InstallTimers(void);
/* called by Embra */
void InstallPoller(void);
/* called by embra to check if address is coherent */
extern int SimMagic_IsIncoherent(uint pAddr);
/* called by flash_interface to report bad cache lines */
extern void SimMagic_MakeIncoherent(uint pAddr);
/* called by flash_interface to extract info from MAGIC that must be
* pushed into Flite when restoring from a checkpoint.
*/
extern unsigned char SimMagic_GetIbitTableEntry(int cpunum, int entry);
extern uint64 SimMagic_GetIECPending(int cpunum);
extern uint64 SimMagic_GetIECTrans(int cpunum);
extern uint64 SimMagic_GetIECEnable(int cpunum);
/* interrupt raise/clear. This is used by some of the simulators for
* internally generated interrupts.
*/
void RaiseIBit(int cpu, IEC code);
void ClearIBit(int cpu, IEC code);
extern Result SimMagic_DoPIO(int cpuNum, PA addr,
int isRead, int size, void *data);
/*
* Structure and macros used to get the machine number from a device number
*/
typedef struct devicetomachinestruct {
int *console;
int *ether;
int *clock;
} DeviceToMachineStruct;
#define M_FROM_CONSOLE(_d) deviceToMachine.console[_d]
#define M_FROM_ETHER_CONTROLLER(_d) deviceToMachine.ether[_d]
#define M_FROM_CLOCK(_d) deviceToMachine.clock[_d]
extern DeviceToMachineStruct deviceToMachine;
#endif /* _SIM_MAGIC_H */