mirror of
https://github.com/rdolbeau/NuBusFPGA.git
synced 2025-01-21 23:30:32 +00:00
use some custom RLE to initiliaze the RAM disk with a valid HFS FS. Still doesn't mount at boot though.
This commit is contained in:
parent
2000161727
commit
972f628e80
@ -13,7 +13,7 @@ HRES=1920
|
||||
VRES=1080
|
||||
|
||||
CSRC_VIDEO=NuBusFPGADrvr_OpenClose.c NuBusFPGADrvr_Ctrl.c NuBusFPGADrvr_Status.c NuBusFPGAPrimaryInit_Primary.c NuBusFPGASecondaryInit_Secondary.c
|
||||
CSRC_RAMDSK=NuBusFPGARAMDskDrvr_OpenClose.c NuBusFPGARAMDskDrvr_Ctrl.c NuBusFPGARAMDskDrvr_Prime.c NuBusFPGARAMDskDrvr_Status.c
|
||||
CSRC_RAMDSK=NuBusFPGARAMDskDrvr_OpenClose.c NuBusFPGARAMDskDrvr_Ctrl.c NuBusFPGARAMDskDrvr_Prime.c NuBusFPGARAMDskDrvr_Status.c myrle.c
|
||||
CSRC=${CSRC_VIDEO} ${CSRC_RAMDSK}
|
||||
CSRC_ASM=${CSRC:.c=.s}
|
||||
|
||||
@ -60,6 +60,15 @@ NuBusFPGARAMDskDrvr_Status.s: NuBusFPGARAMDskDrvr_Status.c NuBusFPGARAMDskDrvr.h
|
||||
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
|
||||
sed -i -e 's/\.\(L[0-9][0-9]*\)/.RDStatus_\1/g' $@
|
||||
|
||||
myrle.s: myrle.c
|
||||
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DSKIP_MAIN
|
||||
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
|
||||
sed -i -e 's/\.\(L[0-9][0-9]*\)/.myrle_\1/g' $@
|
||||
|
||||
dump_cpr.s: dump_cpr.c
|
||||
${CC} -march=68020 -mcpu=68020 -O2 $< -S -o $@ -DSKIP_MAIN
|
||||
sed -i -e 's/^\([^a-zA-Z0-9_]*\.globl.*\)/# --- \1/' $@
|
||||
sed -i -e 's/\.\(L[0-9][0-9]*\)/.dump_cpr_\1/g' $@
|
||||
|
||||
|
||||
NuBusFPGAPrimaryInit_Primary.s: NuBusFPGAPrimaryInit_Primary.c NuBusFPGADrvr.h
|
||||
|
@ -21,4 +21,6 @@ struct RAMDrvContext {
|
||||
|
||||
#define DRIVE_SIZE_BYTES ((256ul-8ul)*1024ul*1024ul) // FIXME: mem size minus fb size
|
||||
|
||||
uint32_t rledec(uint32_t* out, const uint32_t* in, const uint32_t len);
|
||||
|
||||
#endif
|
||||
|
@ -92,5 +92,7 @@ _RAMDskGoIODone:
|
||||
.text
|
||||
.include "NuBusFPGARAMDskDrvr_Status.s"
|
||||
.text
|
||||
.include "myrle.s"
|
||||
.text
|
||||
|
||||
ALIGN 2
|
||||
|
@ -7,8 +7,8 @@ OSErr cNuBusFPGARAMDskCtl(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
||||
|
||||
dce->dCtlDevBase = 0xfc000000;
|
||||
|
||||
/* write_reg(dce, GOBOFB_DEBUG, 0xDEAD0002); */
|
||||
/* write_reg(dce, GOBOFB_DEBUG, pb->csCode); */
|
||||
write_reg(dce, GOBOFB_DEBUG, 0xDEAD0002);
|
||||
write_reg(dce, GOBOFB_DEBUG, pb->csCode);
|
||||
|
||||
ctx = *(struct RAMDrvContext**)dce->dCtlStorage;
|
||||
|
||||
|
@ -13,7 +13,7 @@ OSErr cNuBusFPGARAMDskOpen(IOParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
||||
|
||||
dce->dCtlDevBase = 0xfc000000;
|
||||
|
||||
/* write_reg(dce, GOBOFB_DEBUG, 0xDEAD0000); */
|
||||
write_reg(dce, GOBOFB_DEBUG, 0xDEAD0000);
|
||||
/* write_reg(dce, GOBOFB_DEBUG, dce->dCtlRefNum); */
|
||||
|
||||
if (dce->dCtlStorage == nil) {
|
||||
@ -50,8 +50,32 @@ OSErr cNuBusFPGARAMDskOpen(IOParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
||||
// dsptr->driveChar
|
||||
// dsptr->driveMisc
|
||||
|
||||
// MyAddDrive(dsptr->dQRefNum, drvnum, (DrvQElPtr)&dsptr->qLink);
|
||||
|
||||
// write_reg(dce, GOBOFB_DEBUG, 0x0000DEAD);
|
||||
{
|
||||
unsigned char* superslot = 0xc0000000; // FIXME
|
||||
unsigned long *compressed = 0xFcFF8000; // FIXME
|
||||
unsigned long res;
|
||||
/*
|
||||
write_reg(dce, GOBOFB_DEBUG, 0xDEAD0000);
|
||||
write_reg(dce, GOBOFB_DEBUG, compressed);
|
||||
write_reg(dce, GOBOFB_DEBUG, compressed[0]);
|
||||
write_reg(dce, GOBOFB_DEBUG, compressed[1]);
|
||||
write_reg(dce, GOBOFB_DEBUG, compressed[2]);
|
||||
write_reg(dce, GOBOFB_DEBUG, compressed[3]);
|
||||
*/
|
||||
res = rledec(superslot, compressed, 730);
|
||||
/*
|
||||
write_reg(dce, GOBOFB_DEBUG, res);
|
||||
write_reg(dce, GOBOFB_DEBUG, 0xDEEEEEAD);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
MyAddDrive(dsptr->dQRefNum, drvnum, (DrvQElPtr)&dsptr->qLink);
|
||||
}
|
||||
|
||||
|
||||
done:
|
||||
return ret;
|
||||
|
@ -7,7 +7,8 @@ OSErr cNuBusFPGARAMDskStatus(CntrlParamPtr pb, /* DCtlPtr */ AuxDCEPtr dce)
|
||||
|
||||
dce->dCtlDevBase = 0xfc000000;
|
||||
|
||||
/* write_reg(dce, GOBOFB_DEBUG, 0xDEAD0004); */
|
||||
write_reg(dce, GOBOFB_DEBUG, 0xDEAD0004);
|
||||
write_reg(dce, GOBOFB_DEBUG, pb->csCode);
|
||||
|
||||
ctx = *(struct RAMDrvContext**)dce->dCtlStorage;
|
||||
|
||||
|
BIN
nubus-to-ztex-gateware/DeclROM/dump.cpr
Executable file
BIN
nubus-to-ztex-gateware/DeclROM/dump.cpr
Executable file
Binary file not shown.
144
nubus-to-ztex-gateware/DeclROM/myrle.c
Normal file
144
nubus-to-ztex-gateware/DeclROM/myrle.c
Normal file
@ -0,0 +1,144 @@
|
||||
#include <stdint.h>
|
||||
|
||||
//#include <stdio.h>
|
||||
|
||||
#ifndef SKIP_MAIN
|
||||
uint32_t rleenc(uint32_t* out, const uint32_t* in, const uint32_t len) {
|
||||
uint32_t i = 0, j = 0, p = 0, ib, k;
|
||||
int32_t c = 0;
|
||||
|
||||
p = in[0];
|
||||
|
||||
for (i = 1 ; i < len ; i++) {
|
||||
if (c == 0) { // just started
|
||||
if (in[i] == p) { // repeat
|
||||
c++;
|
||||
} else { // non-repeat
|
||||
p = in[i];
|
||||
c--;
|
||||
ib = i - 1;
|
||||
}
|
||||
} else if (c > 0) { // in-repeat
|
||||
if (in[i] == p) { // keep repeating
|
||||
c++;
|
||||
} else { // exit repeat
|
||||
out[j++] = __builtin_bswap32(c); // write result
|
||||
out[j++] = p;
|
||||
p = in[i]; // restart
|
||||
c = 0;
|
||||
}
|
||||
} else { // c < 0
|
||||
if (in[i] == p) { // exit non-repeat
|
||||
out[j++] = __builtin_bswap32(c+1); // write result, removing previous
|
||||
for (k = 0 ; k < (-c) ; k++)
|
||||
out[j++] = in[ib+k];
|
||||
p = in[i]; // restart
|
||||
c = 1; // this and previous
|
||||
} else { // non-repeat
|
||||
p = in[i];
|
||||
c--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
out[j++] = __builtin_bswap32(c);
|
||||
out[j++] = p;
|
||||
|
||||
return j;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
uint32_t rledec(uint32_t* out, const uint32_t* in, const uint32_t len) {
|
||||
uint32_t i = 0, j = 0, k = 0, chk = 0, ib;
|
||||
|
||||
for (i = 0 ; i < len ; ) {
|
||||
#ifndef __m68k__
|
||||
int32_t c = (int32_t)__builtin_bswap32(in[i]);
|
||||
#else
|
||||
int32_t c = (int32_t)(in[i]);
|
||||
#endif
|
||||
if (c >= 0) {
|
||||
chk += (1 + c);
|
||||
if (c < 10000) // !!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
for (k = 0 ; k < c+1 ; k++)
|
||||
out[j++] = in[i+1];
|
||||
else
|
||||
j += c+1;
|
||||
i += 2;
|
||||
} else {
|
||||
chk += 1 + -c;
|
||||
for (k = 0 ; k < 1 + -c ; k++)
|
||||
out[j++] = in[i+1+k];
|
||||
i += 2 + -c;
|
||||
}
|
||||
//fprintf(stderr, "%u: %u <> %u (%d, 0x%08x)\n", i, j, chk, c, in[i+1]);
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
#ifndef SKIP_MAIN
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int fd;
|
||||
uint32_t len, k;
|
||||
uint32_t *bufa, *bufb;
|
||||
FILE* f;
|
||||
|
||||
bufa = calloc(sizeof(uint32_t), 256*1024*1024/sizeof(uint32_t));
|
||||
bufb = calloc(sizeof(uint32_t), 256*1024*1024/sizeof(uint32_t));
|
||||
|
||||
fd = open("dump.raw", O_RDONLY);
|
||||
len = read(fd, bufa, 248*1024*1024ull) / 4;
|
||||
close(fd);
|
||||
|
||||
printf("File : %d bytes\n", len*4);
|
||||
|
||||
len = rleenc(bufb, bufa, len);
|
||||
|
||||
printf("Compressed : %d bytes\n", len*4);
|
||||
|
||||
/* for (k = 0 ; k < len ; k++) */
|
||||
/* bufb[k] = __builtin_bswap32(bufb[k]); */
|
||||
|
||||
fd = open("dump.cpr", O_WRONLY | O_CREAT, S_IRWXU);
|
||||
/* len = */write (fd, bufb, len*4);
|
||||
close(fd);
|
||||
|
||||
/* for (k = 0 ; k < len ; k++) */
|
||||
/* bufb[k] = __builtin_bswap32(bufb[k]); */
|
||||
|
||||
f = fopen("dump_cpr.c", "w");
|
||||
/* fprintf(f, "unsigned char* compressed[%d] = {\n", len*4); */
|
||||
/* for (k = 0 ; k < len*4 ; k++) { */
|
||||
/* fprintf(f, "0x%02x%s", ((unsigned char*)bufb)[k], */
|
||||
/* k == (len*4-1) ? "};" : (k%16 == 15 ? ",\n" : ",") */
|
||||
/* ); */
|
||||
/* } */
|
||||
fprintf(f, "unsigned long* compressed[%d] = {\n", len);
|
||||
for (k = 0 ; k < len ; k++) {
|
||||
fprintf(f, "0x%08x%s", bufb[k],
|
||||
k == (len-1) ? "};" : (k%8 == 7 ? ",\n" : ",")
|
||||
);
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
len = rledec(bufa, bufb, len);
|
||||
|
||||
printf("Uncompressed : %d bytes\n", len*4);
|
||||
|
||||
fd = open("dump.ucp", O_WRONLY | O_CREAT, S_IRWXU);
|
||||
len = write (fd, bufa, len*4);
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user