mirror of
https://github.com/rdolbeau/NuBusFPGA.git
synced 2025-01-11 03:29:45 +00:00
C secondary, add rsrc directory w/o assembly
This commit is contained in:
parent
3be6333be7
commit
44fa491540
@ -1,6 +1,7 @@
|
||||
AS=/home/dolbeau/Retro68/build/toolchain/bin/m68k-apple-macos-as
|
||||
CC=/home/dolbeau/Retro68/build/toolchain/bin/m68k-apple-macos-gcc
|
||||
OBJCOPY=/home/dolbeau/Retro68/build/toolchain/bin/m68k-apple-macos-objcopy
|
||||
HOSTCC=gcc
|
||||
|
||||
NS816DECLROMDIR=/home/dolbeau/ns816-declrom
|
||||
NUBUS_CHECKSUM=${NS816DECLROMDIR}/nubus_checksum
|
||||
@ -11,12 +12,12 @@ APPLEINCS=${NS816DECLROMDIR}/atrap.inc ${NS816DECLROMDIR}/declrom.inc ${NS816DEC
|
||||
HRES=1920
|
||||
VRES=1080
|
||||
|
||||
CSRC=NuBusFPGADrvr_OpenClose.c NuBusFPGADrvr_Ctrl.c NuBusFPGADrvr_Status.c NuBusFPGAPrimaryInit_Primary.c
|
||||
CSRC=NuBusFPGADrvr_OpenClose.c NuBusFPGADrvr_Ctrl.c NuBusFPGADrvr_Status.c NuBusFPGAPrimaryInit_Primary.c NuBusFPGASecondaryInit_Secondary.c
|
||||
CSRC_ASM=${CSRC:.c=.s}
|
||||
|
||||
all: vid_decl_rom.bin vid_decl_rom.srec
|
||||
|
||||
vid_decl_rom.o: vid_decl_rom.s NuBusFPGAPrimaryInit.s NuBusFPGAPrimaryInit_Primary.s NuBusFPGASecondaryInit.s NuBusFPGADrvr.s ${APPLEINCS} ${CSRC_ASM} DepVideo.inc
|
||||
vid_decl_rom.o: vid_decl_rom.s NuBusFPGAPrimaryInit.s NuBusFPGAPrimaryInit_Primary.s NuBusFPGASecondaryInit.s NuBusFPGASecondaryInit_Secondary.s NuBusFPGADrvr.s ${APPLEINCS} ${CSRC_ASM} DepVideo.inc
|
||||
rm -f res.inc
|
||||
echo -e "HRES=${HRES}\nVRES=${VRES}\n" | tee res.inc
|
||||
${AS} -march=68020 -mcpu=68020 -I${NS816DECLROMDIR} $< -o $@ -a > vid_decl_rom.l
|
||||
@ -41,15 +42,27 @@ NuBusFPGAPrimaryInit_Primary.s: NuBusFPGAPrimaryInit_Primary.c NuBusFPGADrvr.h
|
||||
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
|
||||
sed -i -e 's/\.\(L[0-9][0-9]*\)/.PIPrimary_\1/g' $@
|
||||
|
||||
NuBusFPGASecondaryInit_Secondary.s: NuBusFPGASecondaryInit_Secondary.c NuBusFPGADrvr.h
|
||||
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DHRES=${HRES} -DVRES=${VRES}
|
||||
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
|
||||
sed -i -e 's/\.\(L[0-9][0-9]*\)/.PISecondary_\1/g' $@
|
||||
|
||||
vid_decl_rom.srec: vid_decl_rom.o
|
||||
${OBJCOPY} $^ $@ --input-target=elf32-m68k --output-target=srec
|
||||
|
||||
vid_decl_rom.raw: vid_decl_rom.o
|
||||
${OBJCOPY} $^ $@ --input-target=elf32-m68k --output-target=binary
|
||||
|
||||
vid_decl_rom.bin: vid_decl_rom.raw
|
||||
vid_decl_rom.dir: vid_decl_rom.raw append_romdir
|
||||
cp $< $@
|
||||
./append_romdir $@
|
||||
|
||||
vid_decl_rom.bin: vid_decl_rom.dir
|
||||
${NUBUS_CHECKSUM} --input_file $< --output_file $@ --output_size 32768
|
||||
|
||||
clean:
|
||||
rm -f res.inc ${CSRC_ASM} *.o vid_decl_rom.srec vid_decl_rom.raw vid_decl_rom.l
|
||||
rm -f res.inc ${CSRC_ASM} *.o vid_decl_rom.srec vid_decl_rom.raw vid_decl_rom.dir vid_decl_rom.l
|
||||
|
||||
append_romdir: append_romdir.c
|
||||
${HOSTCC} $< -o $@
|
||||
|
||||
|
@ -88,6 +88,5 @@ interruptRoutine:
|
||||
jsr (%a0)
|
||||
moveq #1,%d0
|
||||
rts
|
||||
|
||||
|
||||
ALIGN 2
|
||||
|
||||
ALIGN 2
|
||||
|
@ -104,8 +104,8 @@ OSErr cNuBusFPGACtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
||||
short ret = -1;
|
||||
char busMode = 1;
|
||||
|
||||
write_reg(dce, GOBOFB_DEBUG, 0xBEEF0001);
|
||||
write_reg(dce, GOBOFB_DEBUG, pb->csCode);
|
||||
/* write_reg(dce, GOBOFB_DEBUG, 0xBEEF0001); */
|
||||
/* write_reg(dce, GOBOFB_DEBUG, pb->csCode); */
|
||||
|
||||
#if 1
|
||||
switch (pb->csCode)
|
||||
|
@ -39,8 +39,8 @@ OSErr cNuBusFPGAStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
||||
NuBusFPGADriverGlobalsPtr dStore = *dStoreHdl;
|
||||
short ret = -1;
|
||||
|
||||
write_reg(dce, GOBOFB_DEBUG, 0xBEEF0002);
|
||||
write_reg(dce, GOBOFB_DEBUG, pb->csCode);
|
||||
/* write_reg(dce, GOBOFB_DEBUG, 0xBEEF0002); */
|
||||
/* write_reg(dce, GOBOFB_DEBUG, pb->csCode); */
|
||||
|
||||
#if 1
|
||||
switch (pb->csCode)
|
||||
|
@ -40,6 +40,8 @@ UInt32 Primary(SEBlock* seblock) {
|
||||
}
|
||||
|
||||
SwapMMUMode ( &busMode ); // restore
|
||||
|
||||
#if 0
|
||||
|
||||
/* call SVersion to figure out if we have a recent SlotManager */
|
||||
//spblock.spSlot = seblock->seSlot;
|
||||
@ -98,7 +100,8 @@ UInt32 Primary(SEBlock* seblock) {
|
||||
/* PRIM_WRITEREG(GOBOFB_DEBUG, pram[i]);*/
|
||||
}
|
||||
SwapMMUMode ( &busMode ); // restore
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
seblock->seStatus = 1;
|
||||
|
||||
|
@ -4,35 +4,10 @@
|
||||
.short 0 /* Reserved */
|
||||
.long BeginSecondary-. /* Offset to code. */
|
||||
|
||||
BeginSecondary:
|
||||
movew #1,%A0@(seStatus) /* VendorStatus <- 1 {Code was executed} */
|
||||
movel %A0,%A3 /* save param block */
|
||||
/* Set up a slot parameter block in %A0 */
|
||||
SUBA #smParamBlockSize,%SP /* make an SDM parameter block on stack */
|
||||
movel %SP,%A0 /* get pointer to parm block now */
|
||||
MOVE.B seSlot(%A3),spSlot(%A0) /* put slot in pBlock */
|
||||
CLR.B spExtDev(%A0) /* external device = 0 */
|
||||
|
||||
moveq #8,%D0 /* _sVersion ; find the Slot Manager version */
|
||||
.word 0xA06E /* _sVersion ; find the Slot Manager version */
|
||||
|
||||
MOVEL spResult(%A0),%D1 /* recover result */
|
||||
ADDA #smParamBlockSize,%SP /* drop the slot Parameter block */
|
||||
|
||||
moveq #0,%D0 /* D0 <- 00000000 */
|
||||
MOVEB %A3@(seSlot),%D0 /* D0 <- 0000000s */
|
||||
LSLW #4,%D0 /* D0 <- 000000s0 */
|
||||
/* OR.B %A3@(seSlot),%D0 /* D0 <- 000000ss */
|
||||
OR.W #0xF00,%D0 /* D0 <- 00000Fs0 */
|
||||
SWAP %D0 /* D0 <- 0Fs00000 */
|
||||
LSLL #4,%D0 /* D0 <- Fs000000 */
|
||||
MOVEAL %D0,%A1
|
||||
|
||||
/* param block in %A3, our HW (32-bits mode) in %A1 */
|
||||
addl #0x00900000, %A1
|
||||
movel #0x0f0f0f0f,%A1@(0x1c) /* marker to qemu */
|
||||
movel %D1,%A1@(0x1c) /*_sVersion spResult to Qemu */
|
||||
|
||||
ExitSecondary:
|
||||
RTS /* Return */
|
||||
|
||||
BeginSecondary:
|
||||
MOVE.L %A0, -(%A7)
|
||||
JSR Secondary
|
||||
MOVE.L (%A7)+, %a0
|
||||
rts
|
||||
.include "NuBusFPGASecondaryInit_Secondary.s"
|
||||
.text
|
||||
|
@ -0,0 +1,133 @@
|
||||
#include "NuBusFPGADrvr.h"
|
||||
|
||||
#include <Traps.h>
|
||||
|
||||
#define SECO_WRITEREG(reg, val) \
|
||||
*((volatile UInt32*)(a32+GOBOFB_BASE+reg)) = (UInt32)val;
|
||||
|
||||
UniversalProcPtr toto;
|
||||
|
||||
void local_BitBlt(void);
|
||||
asm(" .ALIGN 2\n"
|
||||
" .type local_BitBlt, @function\n"
|
||||
"local_BitBlt:\n"
|
||||
" move.l %a0,-(%sp)\n"
|
||||
" move.l #0xfc90001c, %a0\n"
|
||||
" move.l #0xDEADBEEF, (%a0)\n"
|
||||
" /* move.l %pc@(orig_BitBlt), (%a0) */\n"
|
||||
" move.l %sp@(4), (%a0)\n"
|
||||
" move.l %a1, (%a0)\n"
|
||||
" move.l %a2, (%a0)\n"
|
||||
" move.l %a3, (%a0)\n"
|
||||
" move.l %a4, (%a0)\n"
|
||||
" move.l %a5, (%a0)\n"
|
||||
" move.l %a6, (%a0)\n"
|
||||
" move.l %a2@(0),(%a0)\n"
|
||||
" move.l %a2@(4),(%a0)\n"
|
||||
" move.l %a3@(0),(%a0)\n"
|
||||
" move.l %a3@(4),(%a0)\n"
|
||||
" move.l (%sp)+,%a0\n"
|
||||
" move.l %pc@(toto),(%a0)\n"
|
||||
" move.l %pc@(toto),-(%sp)\n"
|
||||
" rts\n"
|
||||
".size local_BitBlt, .-local_BitBlt\n"
|
||||
);
|
||||
|
||||
UInt32 Secondary(SEBlock* seblock) {
|
||||
UInt32 a32 = 0xF0000000 | ((UInt32)seblock->seSlot << 24);
|
||||
UInt32 a32_l0, a32_l1;
|
||||
UInt32 a32_4p0, a32_4p1;
|
||||
SpBlock spblock;
|
||||
UInt8 pram[8];
|
||||
OSErr err;
|
||||
UInt16 i,j;
|
||||
char busMode;
|
||||
UniversalProcPtr qd32ptr, unimpptr;
|
||||
|
||||
busMode = 1;
|
||||
|
||||
/* call SVersion to figure out if we have a recent SlotManager */
|
||||
#if 0
|
||||
//spblock.spSlot = seblock->seSlot;
|
||||
//spblock.spExtDev = 0;
|
||||
err = SVersion(&spblock);
|
||||
|
||||
busMode = 1;
|
||||
SwapMMUMode ( &busMode ); // to32
|
||||
if (err) {
|
||||
/* DCDMF3 p178: if error, old slot manager*/
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, 0xFFFFFFFF);*/
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, err);*/
|
||||
} else {
|
||||
/* DCDMF3 p178: new slot manager */
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, 0);*/
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, spblock.spResult);*/
|
||||
}
|
||||
SwapMMUMode ( &busMode ); // restore
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
/* check for 32-bits QuickDraw */
|
||||
qd32ptr = GetTrapAddress(Check32QDTrap);
|
||||
unimpptr = GetTrapAddress(_Unimplemented);
|
||||
|
||||
busMode = 1;
|
||||
SwapMMUMode ( &busMode ); // to32
|
||||
if (qd32ptr == unimpptr) {
|
||||
/* no 32QD */
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, 0xFFFFFFFF);
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, unimpptr);
|
||||
} else {
|
||||
/* yes 32QD */
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, 0x00C0FFEE);
|
||||
}
|
||||
SwapMMUMode ( &busMode ); // restore
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/* check the content of the PRAM */
|
||||
spblock.spSlot = seblock->seSlot;
|
||||
spblock.spResult = (UInt32)pram;
|
||||
err = SReadPRAMRec(&spblock);
|
||||
|
||||
#if 0
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, 0x88888888);
|
||||
for (j = 0 ; j < 8 ; j++)
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, (uint32_t)pram[j]);
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, 0x88888888);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
busMode = 1;
|
||||
SwapMMUMode ( &busMode ); // to32
|
||||
if (err) {
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, 0xFFFFFFFF);*/
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, err);*/
|
||||
} else {
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, 0xC0FFEE00);*/
|
||||
/* for (i = 0 ; i < 8 ; i++) */
|
||||
/* SECO_WRITEREG(GOBOFB_DEBUG, pram[i]);*/
|
||||
}
|
||||
SwapMMUMode ( &busMode ); // restore
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// patch some traps
|
||||
UniversalProcPtr orig_BitBlt = GetToolTrapAddress(0xAB00); // BitBlt
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, orig_BitBlt);
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, unimpptr);
|
||||
toto = orig_BitBlt;
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, toto);
|
||||
UniversalProcPtr tutu;
|
||||
asm("lea %%pc@(local_BitBlt),%0\n" : "=a"(tutu));
|
||||
SECO_WRITEREG(GOBOFB_DEBUG, tutu);
|
||||
SetToolTrapAddress(orig_BitBlt, 0xAB00);
|
||||
#endif
|
||||
|
||||
seblock->seStatus = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
83
nubus-to-ztex-gateware/DeclROM/append_romdir.c
Normal file
83
nubus-to-ztex-gateware/DeclROM/append_romdir.c
Normal file
@ -0,0 +1,83 @@
|
||||
// 00 00 10 0a 00 00 00 00 01 01 5a 93 2b c7 00 0f
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
struct dir {
|
||||
uint32_t oslt;
|
||||
uint32_t length;
|
||||
uint32_t crc;
|
||||
uint8_t one;
|
||||
uint8_t appleformat;
|
||||
uint8_t tp0;
|
||||
uint8_t tp1;
|
||||
uint8_t tp2;
|
||||
uint8_t tp3;
|
||||
uint8_t zero;
|
||||
uint8_t bytelane;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
struct dir data;
|
||||
struct stat buf;
|
||||
int fd;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "no I/O file\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
data.oslt = 0;
|
||||
data.length = 0;
|
||||
data.crc = 0;
|
||||
data.one = 1;
|
||||
data.appleformat = 1;
|
||||
data.tp0 = 0x5a;
|
||||
data.tp1 = 0x93;
|
||||
data.tp2 = 0x2b;
|
||||
data.tp3 = 0xc7;
|
||||
data.zero = 0;
|
||||
data.bytelane = 0x0F;
|
||||
|
||||
if (stat(argv[1], &buf)) {
|
||||
fprintf(stderr, "stat: %d -> %s\n", errno, strerror(errno));
|
||||
exit(-2);
|
||||
}
|
||||
|
||||
data.length = sizeof(data) + buf.st_size;
|
||||
|
||||
printf("size is %u\n", data.length);
|
||||
|
||||
//.long (\entry_type<<24) + ((\label-.) & 0xffffff)
|
||||
data.oslt = 0x00 << 24 | (-buf.st_size) & 0xFFFFFF;
|
||||
|
||||
printf("entry is 0x%08x\n", data.oslt);
|
||||
|
||||
data.length = __builtin_bswap32(data.length);
|
||||
data.oslt = __builtin_bswap32(data.oslt);
|
||||
|
||||
if ((fd = open(argv[1], O_WRONLY | O_APPEND)) == -1) {
|
||||
fprintf(stderr, "open: %d -> %s\n", errno, strerror(errno));
|
||||
exit(-3);
|
||||
}
|
||||
|
||||
write(fd, &data, sizeof(data));
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
@ -272,18 +272,3 @@ _HRV24Parms:
|
||||
.long defmPlaneBytes /* bmPlaneBytes */
|
||||
_EndHRV24Parms:
|
||||
|
||||
/* Declaration ROM directory at end */
|
||||
ALIGN 2
|
||||
DeclROMDir:
|
||||
OSLstEntry 0, _sRsrcDir
|
||||
.long DeclRomEnd-_sRsrcDir /* Length should be 0x824 */
|
||||
DeclROMCRC:
|
||||
.long 0x0 /* TODO: calculate this */
|
||||
.byte 1 /* Revision Level */
|
||||
.byte appleFormat /* Apple Format */
|
||||
.long testPattern /* magic TestPattern */
|
||||
.byte 0 /* reserved */
|
||||
.byte 0x0F /* byte lane marker */
|
||||
DeclRomEnd:
|
||||
.end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user