Source to jet/os.c


Enter a symbol's name here to quickly find it.

#include <OSUtils.h>
#include <Memory.h>

#include "jet.h"

unsigned short mac2time(unsigned long secs)
{
	DateTimeRec dtrp;
	
	Secs2Date(secs, &dtrp);
	return ((dtrp.hour << 11) | (dtrp.minute << 5) | (dtrp.second >> 1));
}

unsigned short mac2date(unsigned long secs)
{
	DateTimeRec dtrp;
	
	Secs2Date(secs, &dtrp);
	return (((dtrp.year - 1980) << 9) | (dtrp.month << 5) | (dtrp.day));
}

unsigned short t_gettime(void)
{
	unsigned long secs;

	GetDateTime(&secs);
	return mac2time(secs);
}

unsigned short t_getdate(void)
{
	unsigned long secs;
  
	GetDateTime(&secs);
	return mac2date(secs);
}

/* only support -1, 0 from user mode, x from super mode */
long s_uper(void *stack)
{
	int in_super;
	long r;
	
	in_super = call_sr & 0x2000;
	if (stack == (void *) -1) {
		r = in_super ? -1L : 0;
	} else {
		r = call_sp;
		if (in_super)
			call_sp = (long) stack; /* should unhold here but exittoshell does */
		else if (vm) {
			if (HoldMemory((long *) r - 16384,65536)!=0) /* pot shot at necessary stack size */
				 asm(".word 0xa9ff");
		}
		call_sr ^= 0x2000;
	}
	return r;
}

long s_upexec(long (*func)(void))
{
	/* we are going back to mint so setup the vectors */
	put_vector();
	return (*func)();
}

long b_setexc(short vnum, long vptr)
{
	long old;

	switch (vnum) {
	case 0x102:
		old = sysvar.term;
		sysvar.term = vptr;
		break;
	default:
		old = -1;
		break;
	}
	return old;
}