/*
C Utility program utils1.c.
Gives miscelaneous info to the system
*/
#include "SparcSoftcardOps.h"
#define realTimeCounterByte 0x384e06
/* to be included inside SparcSoftcard.h */
#define startAddressPos 8
#define memTrapStartPos 0xc
#define memCommStartPos 0x10
#define commLengthPos 0x14
#define memTextStartPos 0x18
#define textLengthPos 0x1c
#define memDataStartPos 0x20
#define dataLengthPos 0x24
#define memBssStartPos 0x28
#define bssLengthPos 0x2c
#define memSymbolStartPos 0x30
#define symbolLengthPos 0x34
#define memEndPos 0x38
#define stackSizePos 0x3c
static int readAccess (address)
int address;
{
int *p;
p = (int *) address;
return (*p);
};
static void writeAccess (address, data)
int address, data;
{
int *p;
p = (int *) address;
*p = data;
};
void SetMemEnd ( end )
int end;
{
writeAccess (memEndPos, end);
};
void SetStackSize ( size )
int size;
{
writeAccess (stackSizePos, size);
};
int MemEnd () {
int mem;
mem = readAccess (memEndPos);
return (mem);
};
int StackSize () {
int stack;
stack = readAccess (stackSizePos);
return (stack);
};
int HeapStart () {
int heap;
heap = readAccess (memSymbolStartPos) + readAccess (symbolLengthPos);
return (heap);
};
int HeapEnd () {
int heap;
heap = readAccess (memEndPos) - readAccess (stackSizePos);
return (heap);
};
int CommStart () {
int comm;
comm = readAccess (memCommStartPos);
return (comm);
};
int CommEnd () {
int comm;
comm = readAccess (memCommStartPos) + readAccess (commLengthPos);
return (comm);
};
void CacheFlushAndEnable () {
long i, *p, x;
SparcSoftcardOps←SparcCacheDisable();
for (i = 0; i < 0x40000; i += 8) {
p = (long *) i;
x = *p;
};
SparcSoftcardOps←SparcCacheEnable();
};
void SetDisplay (byteAddress)
long byteAddress;
{
if ( byteAddress == 0 ) {
SparcSoftcardOps←SetDMAState(DMAState←inactive);
}
else {
SparcSoftcardOps←SetDMAState(DMAState←inactive);
SparcSoftcardOps←SetDMAMode(DMAMode𡤍isplay);
SparcSoftcardOps𡤍MAAddressRegisterLoad(byteAddress);
SparcSoftcardOps←SetDMAState(DMAState�tive);
};
};
extern long RealTimeClockHigh;
long RealTimeCounter ()
{
long rtc, low, high0, high1;
do {
high0 = RealTimeClockHigh;
low = (io←peek (realTimeCounterByte)) & 0xffff;
high1 = RealTimeClockHigh;
} while (high0 != high1);
rtc = high0 << 16;
rtc = rtc + low;
return (rtc);
};