;--------------------------------------------------------------------- ; ; File: VSCPrimaryInit.a ; ; Written by: Gary Rensberger, based on Mike Puckets Sonora PrimaryInit. Jan 4, 1992 ; ; Copyright: © 1988-1993 by Apple Computer, Inc. All rights reserved. ; ; Change History (most recent first): ; ; 12/13/93 PN Roll in KAOs and Horror changes to support Malcom and AJ ; machines ; <1> 12-04-92 jmp first checked in ; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ ; Pre-SuperMario comments begin here. ; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ ; 7/14/92 HJR Enable CSync back on VGA monitors. ;
7/13/92 HJR Disable CSync on VGA monitors. Reverse polarity of PmgrExtVidOn ; and call PmgrHook if Video is enabled. ;
6/30/92 HJR General Cleanup. ;

6/1/92 HJR Check if charger is installed. If not, kill power to external ; video and notify user that something is wrong. Also if video is ; disable, return error so that slot manager can mark slot as ; being bad. ;

5/7/92 HJR Changed VideoBase to VSCVideoBase. ;

4/27/92 HJR Turn off clocks to the VSC if no monitor is detected. ; <1> 4/24/92 HJR first checked in ; <12> 3/5/92 RLE turn off change <10> for Deskbars ; <11> 3/5/92 GMR Fixed a0 register trash bug from change <9> ; <10> 3/4/92 RLE set up nuchip33 to pass Nubus accesses in superslot 6, slot E, ; and superslot E to DB Lite system without translation ; <9> 3/4/92 GMR Now properly setting clock after alternate family mode detected. ; <8> 2/27/92 RLE turn off eject and ethernet interrupt enables ; <7> 2/13/92 RLE move power plane stuff into secondary init where the scc init ; will take place ; <6> 2/6/92 RLE renamed board ID so it works with either Gemini or Deskbar ; <5> 1/31/92 GMR Made the slot interrupt handler more robust. ; <4> 1/31/92 RLE fix stoopid power plane bset bug ; <3> 1/30/92 RLE turn on all power planes, setup new SCC base addresses (until ; docking stuff in place) ; <2> 1/30/92 GMR Now installs a slot E handler for NuBus slots C and D. ; <1> 1/28/92 GMR first checked in ;--------------------------------------------------------------------- ;--------------------------------------------------------------------- ; Header ;--------------------------------------------------------------------- dc.b sExec2 ; Header dc.b sCPU68020 dc.w 0 dc.l BeginVSCInit-* ;--------------------------------------------------------------------- ; Local variables, definitions, etc.... ;--------------------------------------------------------------------- WITH SEBlock,SPBlock VSCFrame RECORD {A6Link},Decrement Return ds.l 1 ; Return address. A6Link ds.l 1 ; Saved A6. memMode ds.l 1 ; 24/32 bit (from swapMMUMode) spBlk ds SPBlock ; SpBlock for generic use. sPRAMBlk ds.b SizeSPRAMRec ; sPRAMRec for generic use. vidParamsPtr ds.l 1 ; Pointer to video parameters. configParamsPtr ds.l 1 ; Pointer to config parameters. startingConfig Ds.b 1 ; Used to determine if we need to reload configs. Ds.b 1 ; SFSize EQU * ENDR ENDWITH VRAMConfigRec RECORD 0 ; sRsrcID ds.b 1 ; Default sRsrc ID for this vRam configuration. alt1 ds.b 1 ; Éfamily mode alternative 1, alt2 ds.b 1 ; Éfamily mode alternative 2, alt3 ds.b 1 ; Éfamily mode alternative 3. modeID ds.b 1 ; Favored modeID (depth). ds.b 1 ; VRAMConfigSize EQU * ENDR MiniGamma RECORD 0 ; Entries for mini gamma table used in VSCInit. blackRed ds.b 1 ; Red whiteRed ds.b 1 ; blackGreen ds.b 1 ; Green whiteGreen ds.b 1 ; blackBlue ds.b 1 ; Blue whiteBlue ds.b 1 ; ds.b 2 ; GT_Size EQU * ENDR WITH MiniGamma,VRAMConfigRec VSCConfigRec Record 0 gammaTbl ds.b GT_Size ; Mini-gamma table SConfigHdrSize EQU * s512KVRAM ds.b VRAMConfigSize ; 512K vRAM preferences. SConfigRecSize EQU * ENDR ENDWITH ;===================================================================== ; Utils ;===================================================================== ;--------------------------------------------------------------------- ; ; Routine: PruneList ; ; Inputs: d0.b - sRsrcID of the ÒkeeperÓ ; d3.l - sRsrcID of 4 family-mode alternates ; a0 - pointer to appropriately filled-out SpBlock ; a1 - pointer to list of sRsrcIDs ; ; Outputs: none ; ; Destroys: d0-d2/a1 ; ; Function: Loops thru a table of sRsrcIDs comparing the ÒkeeperÓ with each ; of the entries in the table. Those IDs that donÕt match ; the keeper or alternate ID's are pruned. Those that don't match ; the keeper, but match one of the alternate ID's will be disabled. ;--------------------------------------------------------------------- WITH SpBlock PruneList move.b d0,-(sp) ; Remember the ID of the Òkeeper.Ó move.w (a1)+,d1 ; Get the zero-based counter into D1. Move.l D3,D2 ; Get the list of family modes. Andi.l #$00FFFFFF,D2 ; Remember if there are any alternatives. @repeat move.b (a1)+,d0 ; Get an sRsrc ID. cmp.b (sp),d0 ; If itÕs the keeper, beq.s @until ; then donÕt prune it. move.b d0,spID(a0) ; else, set ID so we can prune/disable it Tst.l D2 ; If there are no family-mode alternatives, Beq.s @delete ; then just do the delete. rol.l #8,d3 cmp.b d0,d3 ; else, see if it's an alternate family member beq.s @disable ; yes, then disable it rol.l #8,d3 cmp.b d0,d3 ; see if it's the other alternate family member beq.s @disable ; yes, then disable it rol.l #8,d3 cmp.b d0,d3 ; else, see if it's an alternate family member beq.s @disable ; yes, then disable it rol.l #8,d3 cmp.b d0,d3 ; see if it's the other alternate family member beq.s @disable ; yes, then disable it @delete _sDeleteSRTRec @until dbra d1,@Repeat ; Loop until done. bra.s @exit @disable move.l #1,spParamData(a0) ; Setup to disable this mode. clr.l spsPointer(a0) ; Not a RAM sRsrc. _SetsRsrcState ; Set it. bra.s @until @exit tst.b (sp)+ ; Clean up the stack. rts ; Return to caller. ENDWITH ;--------------------------------------------------------------------- ; ; Routine: Delay8ms ; ; Inputs: a0 - Ptr to VIA1 base ; ; Outputs: none ; ; Destroys: d0 ; ; Function: Delays around 8 us, for ensuring PLL is programmed correctly. ;--------------------------------------------------------------------- Delay8ms move.w TimeVIADB,d0 lsl.w #3,d0 ; 8 ms delay @wait tst.b (a0) dbra d0,@wait rts ;--------------------------------------------------------------------- ; ; Routine: SendPLLData ; ; Inputs: a3 - Ptr to AIV3 base ; d0.l - Data to shift out ; d1.w - Number of bits to shift out minus 1 (n-1) ; ; Outputs: none ; ; Destroys: d0-d2 ; ; Function: Sends the specified data to the PLL through the VIA (AIV3). ;--------------------------------------------------------------------- SendPLLData Move.l D3,-(Sp) ; Save D3 (as itÕs a global). rol.l #6,d0 ; First, move starting bit into bit 6. @nextBit move.l d0,d3 ; Get the data. andi.b #(1< rts Endwith ;================================================================================================== ; Routine: PrimaryInit ; ; Inputs: ; ; Ouputs: ; ; May destroy: d0-d7,a0-a6 ; ; Uses A3 - ptr to AIV3 base ; A4 - ptr to VSC's video register base ;================================================================================================== WITH SEBlock,SPBlock,VSCFrame BeginVSCInit ; Set up initial ÒvendorÓ status. link a6,#SFSize ; Allocate stack space for locals. move.w #seSuccess,seStatus(a0) ; Just say that weÕre okay. ; ; Perform some generic initializations. ; move.b seSlot(A0),spBlk.spSlot(a6) ; Get our slot number from the Slot Manager. clr.b spBlk.spExtDev(a6) ; Why ask why? Just clear this guy. ; ; Initialize the BoardID part of the Slot $E pRAM if necessary, and prune the board sResources. ; With SP_Params lea spBlk(a6),a0 ; Point A0 at our local SpBlock. lea sPRAMBlk(a6),a2 ; Get a pointer to our local SPRAMBlock. move.l a2,spResult(a0) ; Put our pointer in the SpBlock. _sReadPRAMRec ; Read Slot $EÕs pRAM. tst.w SP_BoardID(a2) ; If the board ID is non-zero, bne.s @VSCVideoInit ; then just go on. move.b #sRsrc_Board,spID(a0) ; Otherwise, look for the appropriate board sRsrc. _sRsrcInfo ; Get the spsPointer. move.b #BoardID,spID(a0) ; Set up to get the correct board ID. _sReadWord ; Get it. move.w spResult+2(a0),SP_BoardID(a2) ; Save the board ID into pRAM. move.l A2,spsPointer(a0) ; _InitSlotPRAM ; ; In a ÒclassicÓ PrimaryInit, this is the point in the code where would actually go out to ; detect the kind of display that is connected. However, since that has already been ; done for us by the Docking Manager, we just read the indexed MonID from PRAM here. @VSCVideoInit Moveq #0,D6 ; Clear out the indexed display ID reg. Move.b SP_MonID(A2),D6 ; Load the indexed display ID. ENDWITH ; Get some useful values up front. ; lea VSCVideoBase,a4 ; Get the video base address into a4. lea AIV3Base,a3 ; Point to AIV3 base. ;------------------------------------------------------- ; WeÕll size VRAM later if necessary. For now, just assume ; 512K. See the VRAM sizing notes below. ;------------------------------------------------------- Moveq #0,D4 ; Assume thereÕs 512K of VRAM for now. ;------------------------------------------------------- ; Get the video parameters for this monitor (1bbp) and use to setup the dot-clock ; so we can then size VRAM. ;------------------------------------------------------- WITH VRAMConfigRec,VSCConfigRec lea VSCConfigTable,a1 ; Point to the VSC configuration table. move.w #SConfigRecSize,d0 ; Get the size of each entry into D0. mulu d6,d0 ; Multiply it by the right entry. adda.l d0,a1 ; Skip to the entry we want. move.l a1,configParamsPtr(a6) ; Save it for later. adda.l #SConfigHdrSize,a1 ; Skip past the header. move.w #VRAMConfigSize,d0 ; Get the size of the VRAM entries. mulu d4,d0 ; Multiply by the right entry. adda.l d0,a1 ; Skip to the right VRAM entry. Move.b sRsrcID(A1),D5 ; Get an ÒokayÓ sRsrcID into D5. move.b modeID(a1),d7 ; Get the default mode (depth). move.l sRsrcID(a1),d3 ; get both family ID's (if any) in d3 (for disabling) Clr.l vidParamsPtr(A6) ; Remember that we havenÕt loaded in vidParams yet. Cmpi.b #sRsrc_VSC_NeverMatch,D5 ; If itÕs the null one, then Beq @SetConfig ; just get ready to leave. lea spBlk(a6),a0 ; Point A0 at our local SpBlock. move.b #sRsrc_Board,spID(a0) ; Get the board sRsrc ID that we need. _sRsrcInfo move.b #sVidParmDir,spID(a0) ; Look for the video parameters directory. _sFindStruct move.b D5,spID(a0) ; Look in the directory for this configÕs params. _sGetBlock move.l spResult(a0),a1 ; Get a pointer to the vidParams for this config. move.l a1,vidParamsPtr(a6) ; Save for later disposal. Move.b D5,startingConfig(A6) ; Remember which config we started with. ENDWITH ;------------------------------------------------------- ; Set up the dot-clock chip based on our monitor type. ;------------------------------------------------------- bsr SetDotClock ; setup the dot clock to default config ;------------------------------------------------------- ; Size the amount of VRAM. When done, d4 is set to one of {0,1}, where 0=512K,1=1024K. ; Note: On the Darts and BlackBird, only 512K of VRAM is installed, so we just ; Skip this check. ;------------------------------------------------------- move.b #((1<