Skip to content

Commit

Permalink
Allow console output to be cleanly disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Jan 29, 2024
1 parent 8d08187 commit f8d9ccd
Show file tree
Hide file tree
Showing 25 changed files with 520 additions and 443 deletions.
1 change: 1 addition & 0 deletions X/pseudo.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "../armdefs.h"
#include "armarc.h"
#include "arch/dbugsys.h"
#include "arch/keyboard.h"
#include "archio.h"
#include "../armemu.h"
Expand Down
1 change: 1 addition & 0 deletions X/true.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "../armdefs.h"
#include "armarc.h"
#include "arch/dbugsys.h"
#include "arch/keyboard.h"
#include "archio.h"
#include "../armemu.h"
Expand Down
1 change: 1 addition & 0 deletions amiga/DispKbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "../armdefs.h"
#include "armarc.h"
#include "../arch/dbugsys.h"
#include "../arch/keyboard.h"
#include "../arch/ControlPane.h"
#include "displaydev.h"
Expand Down
13 changes: 7 additions & 6 deletions arch/ReadConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ArcemConfig.h"
#include "ReadConfig.h"
#include "armarc.h"
#include "dbugsys.h"
#include "hdc63463.h"

/* Returns 1 if it was all OK - 0 if it failed
Expand Down Expand Up @@ -48,7 +49,7 @@ int ReadConfigFile(ARMul_State *state)
#endif

if (envvar && (env = getenv(envvar)) == NULL) {
fprintf(stderr, "configuration file is $%s/%s but $%s isn't "
warn_cfg("configuration file is $%s/%s but $%s isn't "
"set.", envvar, basename2, envvar);
return 0;
}
Expand All @@ -65,15 +66,15 @@ int ReadConfigFile(ARMul_State *state)
strcat(tmpbuf, basename2);

if ((fConf = fopen(tmpbuf, "r")) == NULL) {
fprintf(stderr, "couldn't open config file: %s\n", tmpbuf);
warn_cfg("couldn't open config file: %s\n", tmpbuf);
return 0;
}

while (!feof(fConf)) {
char *tptr;

if (fgets(tmpbuf, 1023, fConf)==NULL) {
fprintf(stderr, "Failed to read config file header line\n");
warn_cfg("Failed to read config file header line\n");
return 0;
}

Expand All @@ -93,12 +94,12 @@ int ReadConfigFile(ARMul_State *state)

unsigned int drivenum,numcyl,numheads,numsect,reclength;
if (fscanf(fConf,"%u %u %u %u %u\n",&drivenum,&numcyl,&numheads,&numsect,&reclength)!=5) {
fprintf(stderr,"Failed to read MFM disc data line\n");
warn_cfg("Failed to read MFM disc data line\n");
return 0;
}

if (drivenum>3) {
fprintf(stderr,"Invalid drive number in MFM disc data line\n");
warn_cfg("Invalid drive number in MFM disc data line\n");
return 0;
}

Expand All @@ -107,7 +108,7 @@ int ReadConfigFile(ARMul_State *state)
hArcemConfig.aST506DiskShapes[drivenum].NSectors = numsect;
hArcemConfig.aST506DiskShapes[drivenum].RecordLength = reclength;
} else {
fprintf(stderr,"Unknown configuration file key '%s'\n",tmpbuf);
warn_cfg("Unknown configuration file key '%s'\n",tmpbuf);
return 0;
}
}
Expand Down
24 changes: 12 additions & 12 deletions arch/archio.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ ParseIOCAddr(ARMword address, ARMword *bank, ARMword *speed, ARMword *offset)

*offset = address & 0xffff;

/*fprintf(stderr, "ParseIOCAddr: address=0x%x bank=%u speed=%u offset=0x%x\n",
/*dbug_ioc("ParseIOCAddr: address=0x%x bank=%u speed=%u offset=0x%x\n",
address, *bank, *speed, *offset); */
} /* ParseIOCAddr */

Expand Down Expand Up @@ -331,7 +331,7 @@ GetWord_IOCReg(ARMul_State *state, int Register)

case 0xe: /* FIRQ mask */
Result = ioc.FIRQMask;
fprintf(stderr,"IOCRead: FIRQMask=0x%x\n", Result);
dbug_ioc("IOCRead: FIRQMask=0x%x\n", Result);
break;

case 0x10: /* T0 count low */
Expand All @@ -356,7 +356,7 @@ GetWord_IOCReg(ARMul_State *state, int Register)

default:
Result = 0;
fprintf(stderr, "IOCRead: Read of unknown IOC register %d\n", Register);
warn_ioc("IOCRead: Read of unknown IOC register %d\n", Register);
break;
}

Expand Down Expand Up @@ -465,8 +465,8 @@ PutVal_IOCReg(ARMul_State *state, int Register, ARMword data, bool bNw)
break;

default:
fprintf(stderr,"IOC Write: Bad IOC register write reg=%d data=0x%x\n",
Register, data);
warn_ioc("IOC Write: Bad IOC register write reg=%d data=0x%x\n",
Register, data);
break;
} /* Register */

Expand Down Expand Up @@ -540,8 +540,8 @@ GetWord_IO(ARMul_State *state, ARMword address)
} else {
/* IO-address space unused on Arc hardware */
/*EnableTrace();*/
fprintf(stderr, "Read from non-IOC IO space (addr=0x%08x pc=0x%08x\n",
address, state->pc);
warn_ioc("Read from non-IOC IO space (addr=0x%08x pc=0x%08x\n",
address, state->pc);

return 0;
}
Expand Down Expand Up @@ -612,7 +612,7 @@ PutValIO(ARMul_State *state, ARMword address, ARMword data, bool byteNotword)
if(speed == 1)
{
/* Medium speed, assume HDC */
/*fprintf(stderr,"HDC write: address=0x%x speed=%u\n", address, speed); */
/*dbug_ioc("HDC write: address=0x%x speed=%u\n", address, speed); */
HDC_Write(state, offset, data);
}
else if(speed == 2)
Expand Down Expand Up @@ -660,8 +660,8 @@ PutValIO(ARMul_State *state, ARMword address, ARMword data, bool byteNotword)
} /* Bank switch */
} else {
/* IO-address space unused on Arc hardware */
fprintf(stderr, "Write to non-IOC IO space (addr=0x%x data=0x%08x\n",
address, data);
warn_ioc("Write to non-IOC IO space (addr=0x%x data=0x%08x\n",
address, data);
}
} /* PutValIO */

Expand All @@ -674,7 +674,7 @@ int
IOC_ReadKbdTx(ARMul_State *state)
{
if ((ioc.IRQStatus & IRQB_STX) == 0) {
/*fprintf(stderr, "ArmArc_ReadKbdTx: Value=0x%x\n", ioc.SerialTxData); */
/*dbug_ioc("ArmArc_ReadKbdTx: Value=0x%x\n", ioc.SerialTxData); */
/* There is a byte present (Kart TX not empty) */
/* Mark as empty and then return the value */
ioc.IRQStatus |= IRQB_STX;
Expand All @@ -689,7 +689,7 @@ IOC_ReadKbdTx(ARMul_State *state)
int
IOC_WriteKbdRx(ARMul_State *state, uint8_t value)
{
/*fprintf(stderr, "ArmArc_WriteKbdRx: value=0x%x\n", value); */
/*dbug_ioc("ArmArc_WriteKbdRx: value=0x%x\n", value); */
if (ioc.IRQStatus & IRQB_SRX) {
/* Still full */
return -1;
Expand Down
48 changes: 24 additions & 24 deletions arch/armarc.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,60 +64,60 @@ static void DumpHandler(int sig) {
int i, idx;
ARMword size;

fprintf(stderr,"SIGUSR2 at PC=0x%x\n",ARMul_GetPC(state));
warn("SIGUSR2 at PC=0x%x\n",ARMul_GetPC(state));
signal(SIGUSR2,DumpHandler);
/* Register dump */
fprintf(stderr, "Current registers:\n"
"r0 = %08x r1 = %08x r2 = %08x r3 = %08x\n"
"r4 = %08x r5 = %08x r6 = %08x r7 = %08x\n"
"r8 = %08x r9 = %08x r10 = %08x r11 = %08x\n"
"r12 = %08x r13 = %08x r14 = %08x r15 = %08x\n",
warn("Current registers:\n"
"r0 = %08x r1 = %08x r2 = %08x r3 = %08x\n"
"r4 = %08x r5 = %08x r6 = %08x r7 = %08x\n"
"r8 = %08x r9 = %08x r10 = %08x r11 = %08x\n"
"r12 = %08x r13 = %08x r14 = %08x r15 = %08x\n",
state->Reg[0], state->Reg[1], state->Reg[2], state->Reg[3],
state->Reg[4], state->Reg[5], state->Reg[6], state->Reg[7],
state->Reg[8], state->Reg[9], state->Reg[10], state->Reg[11],
state->Reg[12], state->Reg[13], state->Reg[14], state->Reg[15]);
if(state->Bank == FIQBANK)
{
fprintf(stderr,"USR registers:\n"
"r8 = %08x r9 = %08x r10 = %08x r11 = %08x\n"
"r12 = %08x r13 = %08x r14 = %08x\n",
warn("USR registers:\n"
"r8 = %08x r9 = %08x r10 = %08x r11 = %08x\n"
"r12 = %08x r13 = %08x r14 = %08x\n",
state->RegBank[USERBANK][8], state->RegBank[USERBANK][9],
state->RegBank[USERBANK][10], state->RegBank[USERBANK][11],
state->RegBank[USERBANK][12],
state->RegBank[USERBANK][13], state->RegBank[USERBANK][14]);
}
else if(state->Bank != USERBANK)
{
fprintf(stderr,"USR registers: r13 = %08x r14 = %08x\n",
warn("USR registers: r13 = %08x r14 = %08x\n",
state->RegBank[USERBANK][13], state->RegBank[USERBANK][14]);
}
if(state->Bank != FIQBANK)
{
fprintf(stderr,"FIQ registers:\n"
"r8 = %08x r9 = %08x r10 = %08x r11 = %08x\n"
"r12 = %08x r13 = %08x r14 = %08x\n",
warn("FIQ registers:\n"
"r8 = %08x r9 = %08x r10 = %08x r11 = %08x\n"
"r12 = %08x r13 = %08x r14 = %08x\n",
state->RegBank[FIQBANK][8], state->RegBank[FIQBANK][9],
state->RegBank[FIQBANK][10], state->RegBank[FIQBANK][11],
state->RegBank[FIQBANK][12],
state->RegBank[FIQBANK][13], state->RegBank[FIQBANK][14]);
}
if(state->Bank != IRQBANK)
{
fprintf(stderr,"IRQ registers: r13 = %08x r14 = %08x\n",
warn("IRQ registers: r13 = %08x r14 = %08x\n",
state->RegBank[IRQBANK][13], state->RegBank[IRQBANK][14]);
}
if(state->Bank != SVCBANK)
{
fprintf(stderr,"SVC registers: r13 = %08x r14 = %08x\n",
warn("SVC registers: r13 = %08x r14 = %08x\n",
state->RegBank[SVCBANK][13], state->RegBank[SVCBANK][14]);
}

/* IOC timers */
for(i=0;i<4;i++)
fprintf(stderr,"Timer%d Count %08x Latch %08x\n",i,ioc.TimerCount[i],ioc.TimerInputLatch[i]);
warn("Timer%d Count %08x Latch %08x\n",i,ioc.TimerCount[i],ioc.TimerInputLatch[i]);

/* Memory map */
fprintf(stderr,"MEMC using %dKB page size\n",4<<MEMC.PageSizeFlags);
warn("MEMC using %dKB page size\n",4<<MEMC.PageSizeFlags);
size=1<<(12+MEMC.PageSizeFlags);
for(idx=0;idx<512;idx++)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ static void DumpHandler(int sig) {
}
phys *= size;
mangle = ARMul_ManglePhysAddr(phys);
fprintf(stderr,"log %08x -> phy %08x (pre-mangle %08x) prot %s\n",logadr,mangle,phys,prot[(pt>>8)&3]);
warn("log %08x -> phy %08x (pre-mangle %08x) prot %s\n",logadr,mangle,phys,prot[(pt>>8)&3]);
}
}

Expand All @@ -164,7 +164,7 @@ static void DumpHandler(int sig) {
#endif

if (res==NULL) {
fprintf(stderr,"Could not open memory dump file\n");
warn_data("Could not open memory dump file\n");
return;
};

Expand Down Expand Up @@ -210,7 +210,7 @@ ARMul_MemoryInit(ARMul_State *state)
MEMC.DRAMPageSize = MEMC_PAGESIZE_O_4K;
break;
#else
fprintf(stderr, "256K memory size may not be working right. Rounding up to 512K\n");
warn("256K memory size may not be working right. Rounding up to 512K\n");
/* fall through... */
#endif

Expand Down Expand Up @@ -292,8 +292,8 @@ ARMul_MemoryInit(ARMul_State *state)
#if defined(EXTNROM_SUPPORT)
/* Add the space required by an Extension Rom */
extnrom_size = (extnrom_calculate_size(&extnrom_entry_count)+4095)&~4095;
fprintf(stderr, "extnrom_size = %u, extnrom_entry_count= %u\n",
extnrom_size, extnrom_entry_count);
warn("extnrom_size = %u, extnrom_entry_count= %u\n",
extnrom_size, extnrom_entry_count);
#endif /* EXTNROM_SUPPORT */
dbug("Total ROM size required = %u KB\n",
(MEMC.ROMHighSize + extnrom_size) / 1024);
Expand Down Expand Up @@ -488,10 +488,10 @@ static ARMword ARMul_ManglePhysAddr(ARMword phy)
static void FastMap_SetEntries(ARMul_State *state, ARMword addr,ARMword *data,FastMapAccessFunc func,FastMapUInt flags,ARMword size)
{
FastMapEntry *entry = FastMap_GetEntryNoWrap(state,addr);
// fprintf(stderr,"FastMap_SetEntries(%08x,%08x,%08x,%08x,%08x)\n",addr,data,func,flags,size);
// dbug("FastMap_SetEntries(%08x,%08x,%08x,%08x,%08x)\n",addr,data,func,flags,size);
FastMapUInt offset = ((FastMapUInt)data)-addr; /* Offset so we can just add the phy addr to get a pointer back */
flags |= offset>>8;
// fprintf(stderr,"->entry %08x\n->FlagsAndData %08x\n",entry,flags);
// dbug("->entry %08x\n->FlagsAndData %08x\n",entry,flags);
while(size) {
entry->FlagsAndData = flags;
entry->AccessFunc = func;
Expand Down
Loading

0 comments on commit f8d9ccd

Please sign in to comment.