EMILE/second/driver.c

114 lines
2.5 KiB
C
Raw Normal View History

/*
*
* (c) 2005 Laurent Vivier <Laurent@lvivier.info>
*
*/
2005-10-10 21:42:58 +00:00
#include <stdio.h>
#include <unistd.h>
#include <string.h>
2005-11-08 02:06:40 +00:00
#include <macos/lowmem.h>
#include <macos/devices.h>
#include <macos/video.h>
2005-11-08 02:06:40 +00:00
#include "misc.h"
2005-10-06 21:06:20 +00:00
#if 0
void list_drivers()
{
int i;
short count;
DCtlHandle *currentHandle;
DCtlPtr currentPtr;
DriverHeader *driverPtr, **driverHandle;
char name[256];
int j;
count = LMGetUnitTableEntryCount();
currentHandle = (DCtlEntry ***) LMGetUTableBase();
for (i = 0; i < count; i++)
{
if (!currentHandle[i])
continue;
currentPtr = *(currentHandle[i]);
if (currentPtr->dCtlFlags & dRAMBasedMask)
{
driverHandle = (void*)(currentPtr->dCtlDriver);
if (!driverHandle)
continue;
driverPtr = *driverHandle;
}
else
driverPtr = (void*)(currentPtr->dCtlDriver);
for(j = 0; j < driverPtr->drvrName[0]; j++)
name[j] = driverPtr->drvrName[j + 1];
name[j] = 0;
printf("%s\n", name);
printf(" drvrFlags: %04x\n", driverPtr->drvrFlags);
printf(" drvrDelay: %04x\n", driverPtr->drvrDelay);
printf(" drvrEMask: %04x\n", driverPtr->drvrEMask);
printf(" drvrMenu: %04x\n", driverPtr->drvrMenu);
printf(" drvrOpen: %04x\n", driverPtr->drvrOpen);
printf(" drvrPrime: %04x\n", driverPtr->drvrPrime);
printf(" drvrCtl: %04x\n", driverPtr->drvrCtl);
printf(" drvrStatus: %04x\n", driverPtr->drvrStatus);
printf(" drvrClose: %04x\n", driverPtr->drvrClose);
}
}
#endif
2005-10-10 21:42:58 +00:00
void turn_off_interrupts()
2005-10-06 21:06:20 +00:00
{
int i;
short count;
DCtlHandle *currentHandle;
DCtlPtr currentPtr;
DriverHeader *driverPtr, **driverHandle;
short refnum;
2005-11-08 02:06:40 +00:00
volatile OSErr err; /* because -O2 remove call to PBControlSync() otherwise... */
2005-10-10 21:42:58 +00:00
VDParamBlock pb;
VDFlagRec flag;
char name[256];
int j;
2005-10-06 21:06:20 +00:00
count = LMGetUnitTableEntryCount();
currentHandle = (DCtlEntry ***) LMGetUTableBase();
for (i = 0; i < count; i++)
{
if (!currentHandle[i])
continue;
currentPtr = *(currentHandle[i]);
if (currentPtr->dCtlFlags & dRAMBasedMask)
{
driverHandle = (void*)(currentPtr->dCtlDriver);
if (!driverHandle)
continue;
driverPtr = *driverHandle;
}
else
driverPtr = (void*)(currentPtr->dCtlDriver);
2005-10-10 21:42:58 +00:00
for(j = 0; j < driverPtr->drvrName[0]; j++)
name[j] = driverPtr->drvrName[j + 1];
name[j] = 0;
2005-10-10 21:42:58 +00:00
err = OpenDriver(driverPtr->drvrName, &refnum);
if (err != noErr)
continue;
if (strncmp(name, ".Display", 8) == 0)
{
pb.ioRefNum = refnum;
pb.csCode = 7; /* SetInterrupt */
flag.flag = 1;
pb.csParam = &flag;
err = PBControlSync((ParmBlkPtr) &pb);
}
DrvrRemove(refnum);
2005-10-06 21:06:20 +00:00
}
}