NuBusFPGA/nubus-to-ztex-gateware/DeclROM/NuBusFPGAPrimaryInit_Primary.c

158 lines
4.0 KiB
C
Raw Normal View History

2022-04-17 09:25:48 +00:00
#include "NuBusFPGADrvr.h"
2022-10-08 16:23:01 +00:00
#include "NuBusFPGARAMDskDrvr.h"
2022-04-17 09:25:48 +00:00
#include <Traps.h>
2022-09-18 07:10:04 +00:00
#include <ROMDefs.h>
2022-04-17 09:25:48 +00:00
#define PRIM_WRITEREG(reg, val) \
2022-09-17 15:06:15 +00:00
*((volatile UInt32*)(a32+GOBOFB_BASE+reg)) = (UInt32)val
#define PRIM_READREG(reg) \
(*((volatile UInt32*)(a32+GOBOFB_BASE+reg)))
2022-04-17 09:25:48 +00:00
2022-10-06 21:31:45 +00:00
#pragma parameter __D0 Primary(__A0)
2022-04-17 09:25:48 +00:00
UInt32 Primary(SEBlock* seblock) {
UInt32 a32 = 0xF0000000 | ((UInt32)seblock->seSlot << 24);
UInt32 a32_l0, a32_l1;
UInt32 a32_4p0, a32_4p1;
SpBlock spblock;
/* UInt8 pram[8]; */
2022-04-17 09:25:48 +00:00
OSErr err;
2022-09-17 15:06:15 +00:00
UInt16 i,j, hres, vres;
2022-04-17 09:25:48 +00:00
char busMode;
UniversalProcPtr qd32ptr, unimpptr;
busMode = 1;
SwapMMUMode ( &busMode ); // to32 // this likely won't work on older MacII ???
2022-10-08 16:23:01 +00:00
PRIM_WRITEREG(GOBOFB_VBL_MASK, 0);// disable interrupts on FB
PRIM_WRITEREG(DMA_IRQ_CTL, revb(0x2));// disable/clear interrupts on DSK
2022-04-17 09:25:48 +00:00
2022-10-08 16:23:01 +00:00
/* PRIM_WRITEREG(GOBOFB_DEBUG, 0x87654321);// trace */
/* PRIM_WRITEREG(GOBOFB_DEBUG, busMode);// trace */
2022-04-17 09:25:48 +00:00
2022-09-17 15:06:15 +00:00
hres = __builtin_bswap32((UInt32)PRIM_READREG(GOBOFB_HRES)); // fixme: endianness
vres = __builtin_bswap32((UInt32)PRIM_READREG(GOBOFB_VRES)); // fixme: endianness
2023-01-27 21:25:12 +00:00
/* initialize DRAM controller */
2023-04-16 07:04:21 +00:00
#ifndef QEMU
2023-01-27 21:25:12 +00:00
sdram_init(a32);
2023-04-16 07:04:21 +00:00
#endif
2022-04-17 09:25:48 +00:00
/* grey the screen */
/* should switch to HW ? */
2022-04-17 09:25:48 +00:00
a32_l0 = a32;
2022-09-17 15:06:15 +00:00
a32_l1 = a32 + hres;
for (j = 0 ; j < vres ; j+= 2) {
2022-04-17 09:25:48 +00:00
a32_4p0 = a32_l0;
a32_4p1 = a32_l1;
2022-09-17 15:06:15 +00:00
for (i = 0 ; i < hres ; i += 4) {
2022-04-17 09:25:48 +00:00
*((UInt32*)a32_4p0) = 0xAAAAAAAA;
*((UInt32*)a32_4p1) = 0x55555555;
a32_4p0 += 4;
a32_4p1 += 4;
}
2022-09-17 15:06:15 +00:00
a32_l0 += 2*hres;
a32_l1 += 2*hres;
2022-04-17 09:25:48 +00:00
}
SwapMMUMode ( &busMode ); // restore
2022-09-18 07:10:04 +00:00
{ // disable non-default entries
SpBlock spb;
2022-09-18 07:10:04 +00:00
err = noErr;
do {
spb.spParamData = 1<<foneslot|1<<fnext;
spb.spCategory = catDisplay;
spb.spCType = typeVideo;
spb.spDrvrSW = drSwApple;
spb.spDrvrHW = 0xBEEF;
spb.spTBMask = 0; /* match everything above */
spb.spSlot = seblock->seSlot;
spb.spID = nativeVidMode; /* skip over the 'good' one; we can reset as SNextTypeSRsrc skips disabled */
spb.spExtDev = 0;
err = SNextTypeSRsrc(&spb);
if ((err == noErr) &&
(spb.spSlot == seblock->seSlot) &&
(((UInt8)spb.spID) > (UInt8)nativeVidMode) &&
(((UInt8)spb.spID) < (UInt8)diskResource)) {
spb.spParamData = 1; /* disable */
spb.spSlot = seblock->seSlot;
spb.spExtDev = 0;
SetSRsrcState(&spb);
/* PRIM_WRITEREG(GOBOFB_DEBUG, 0xBEEF000F); */
/* PRIM_WRITEREG(GOBOFB_DEBUG, spb.spID); */
}
} while (err == noErr);
}
#if 0
2022-04-17 09:25:48 +00:00
/* call SVersion to figure out if we have a recent SlotManager */
//spblock.spSlot = seblock->seSlot;
//spblock.spExtDev = 0;
err = SVersion(&spblock);
busMode = 1;
SwapMMUMode ( &busMode ); // to32
if (err) {
/* DCDMF3 p178: if error, old slot manager*/
/* PRIM_WRITEREG(GOBOFB_DEBUG, 0xFFFFFFFF);*/
/* PRIM_WRITEREG(GOBOFB_DEBUG, err);*/
} else {
/* DCDMF3 p178: new slot manager */
/* PRIM_WRITEREG(GOBOFB_DEBUG, 0);*/
/* PRIM_WRITEREG(GOBOFB_DEBUG, spblock.spResult);*/
}
SwapMMUMode ( &busMode ); // restore
/* check for 32-bits QuickDraw */
qd32ptr = GetTrapAddress(Check32QDTrap);
unimpptr = GetTrapAddress(_Unimplemented);
busMode = 1;
SwapMMUMode ( &busMode ); // to32
if (qd32ptr == unimpptr) {
/* no 32QD */
PRIM_WRITEREG(GOBOFB_DEBUG, 0xFFFFFFFF);
PRIM_WRITEREG(GOBOFB_DEBUG, unimpptr);
} else {
/* yes 32QD */
PRIM_WRITEREG(GOBOFB_DEBUG, 0x00C0FFEE);
}
SwapMMUMode ( &busMode ); // restore
/* check the content of the PRAM */
spblock.spSlot = seblock->seSlot;
spblock.spResult = (UInt32)pram;
err = SReadPRAMRec(&spblock);
2022-04-18 09:51:07 +00:00
#if 0
PRIM_WRITEREG(GOBOFB_DEBUG, 0x88888888);
for (j = 0 ; j < 8 ; j++)
PRIM_WRITEREG(GOBOFB_DEBUG, (uint32_t)pram[j]);
PRIM_WRITEREG(GOBOFB_DEBUG, 0x88888888);
#endif
2022-04-17 09:25:48 +00:00
busMode = 1;
SwapMMUMode ( &busMode ); // to32
if (err) {
/* PRIM_WRITEREG(GOBOFB_DEBUG, 0xFFFFFFFF);*/
/* PRIM_WRITEREG(GOBOFB_DEBUG, err);*/
} else {
/* PRIM_WRITEREG(GOBOFB_DEBUG, 0xC0FFEE00);*/
/* for (i = 0 ; i < 8 ; i++) */
/* PRIM_WRITEREG(GOBOFB_DEBUG, pram[i]);*/
}
SwapMMUMode ( &busMode ); // restore
#endif
2022-04-17 09:25:48 +00:00
seblock->seStatus = 1;
return 0;
}
2023-01-27 21:25:12 +00:00
/* SDRAM INIT */