Fixing OpenBIOS compilation with gcc 14.1.

This commit is contained in:
Nicolas Pixel Noble 2024-05-08 20:49:09 -07:00
parent 0aab5b03fc
commit de92daa23f
13 changed files with 59 additions and 47 deletions

View file

@ -29,15 +29,26 @@ SOFTWARE.
#include <stdint.h>
enum IRQ {
IRQ_VBLANK = 1 << 0,
IRQ_GPU = 1 << 1,
IRQ_CDROM = 1 << 2,
IRQ_DMA = 1 << 3,
IRQ_TIMER0 = 1 << 4,
IRQ_TIMER1 = 1 << 5,
IRQ_TIMER2 = 1 << 6,
IRQ_CONTROLLER = 1 << 7,
IRQ_SIO = 1 << 8,
IRQ_SPU = 1 << 9,
IRQ_PIO = 1 << 10,
IRQ_VBLANK_NUMBER = 0,
IRQ_VBLANK = 1 << IRQ_VBLANK_NUMBER,
IRQ_GPU_NUMBER = 1,
IRQ_GPU = 1 << IRQ_GPU_NUMBER,
IRQ_CDROM_NUMBER = 2,
IRQ_CDROM = 1 << IRQ_CDROM_NUMBER,
IRQ_DMA_NUMBER = 3,
IRQ_DMA = 1 << IRQ_DMA_NUMBER,
IRQ_TIMER0_NUMBER = 4,
IRQ_TIMER0 = 1 << IRQ_TIMER0_NUMBER,
IRQ_TIMER1_NUMBER = 5,
IRQ_TIMER1 = 1 << IRQ_TIMER1_NUMBER,
IRQ_TIMER2_NUMBER = 6,
IRQ_TIMER2 = 1 << IRQ_TIMER2_NUMBER,
IRQ_CONTROLLER_NUMBER = 7,
IRQ_CONTROLLER = 1 << IRQ_CONTROLLER_NUMBER,
IRQ_SIO_NUMBER = 8,
IRQ_SIO = 1 << IRQ_SIO_NUMBER,
IRQ_SPU_NUMBER = 9,
IRQ_SPU = 1 << IRQ_SPU_NUMBER,
IRQ_PIO_NUMBER = 10,
IRQ_PIO = 1 << IRQ_PIO_NUMBER,
};

View file

@ -630,7 +630,7 @@ static const struct Device s_cardDevice = {
.flags = 0x14,
.blockSize = 0x80,
.desc = "MEMORY CARD",
.init = psxdummy,
.init = (void (*)())psxdummy,
.open = dev_bu_open,
.action = psxdummy,
.close = dev_bu_close,

View file

@ -53,8 +53,7 @@ void initializeCDRomHandlersAndEvents() {
static void initializeSoftwareAndHardware() {
initializeCDRomHandlersAndEvents();
while (!syscall_cdromInnerInit())
;
while (!syscall_cdromInnerInit());
}
void initCDRom() {
@ -78,8 +77,7 @@ int cdromBlockGetStatus() {
uint8_t status;
int cyclesToWait = 9;
while (!syscall_cdromGetStatus(&status) && (--cyclesToWait > 0))
;
while (!syscall_cdromGetStatus(&status) && (--cyclesToWait > 0));
if (cyclesToWait < 1) {
syscall_exception(0x44, 0x1f);
return -1;
@ -101,7 +99,7 @@ static const struct Device s_cdromDevice = {
.flags = 0x14,
.blockSize = 0x800,
.desc = "CD-ROM",
.init = psxdummy,
.init = (void (*)())psxdummy,
.open = dev_cd_open,
.action = psxdummy,
.close = psxdummy,

View file

@ -77,48 +77,48 @@ static __attribute__((section(".ramtext"))) int IRQVerifier(void) {
// guaranteed to not lose any IRQs.
if ((IMASK & IREG & IRQ_CDROM) != 0) {
deliverEvent(EVENT_CDROM, 0x1000);
if (s_IRQsAutoAck[IRQ_CDROM]) IREG &= ~IRQ_CDROM;
if (s_IRQsAutoAck[IRQ_CDROM_NUMBER]) IREG &= ~IRQ_CDROM;
}
if ((IMASK & IREG & IRQ_SPU) != 0) {
deliverEvent(EVENT_SPU, 0x1000);
if (s_IRQsAutoAck[IRQ_SPU]) IREG &= ~IRQ_SPU;
if (s_IRQsAutoAck[IRQ_SPU_NUMBER]) IREG &= ~IRQ_SPU;
}
if ((IMASK & IREG & IRQ_GPU) != 0) {
deliverEvent(EVENT_GPU, 0x1000);
if (s_IRQsAutoAck[IRQ_GPU]) IREG &= ~IRQ_GPU;
if (s_IRQsAutoAck[IRQ_GPU_NUMBER]) IREG &= ~IRQ_GPU;
}
if ((IMASK & IREG & IRQ_PIO) != 0) {
deliverEvent(EVENT_PIO, 0x1000);
if (s_IRQsAutoAck[IRQ_PIO]) IREG &= ~IRQ_PIO;
if (s_IRQsAutoAck[IRQ_PIO_NUMBER]) IREG &= ~IRQ_PIO;
}
if ((IMASK & IREG & IRQ_SIO) != 0) {
deliverEvent(EVENT_SIO, 0x1000);
if (s_IRQsAutoAck[IRQ_SIO]) IREG &= ~IRQ_SIO;
if (s_IRQsAutoAck[IRQ_SIO_NUMBER]) IREG &= ~IRQ_SIO;
}
if ((IMASK & IREG & IRQ_VBLANK) != 0) {
deliverEvent(EVENT_VBLANK, 0x1000);
if (s_IRQsAutoAck[IRQ_VBLANK]) IREG &= ~IRQ_VBLANK;
if (s_IRQsAutoAck[IRQ_VBLANK_NUMBER]) IREG &= ~IRQ_VBLANK;
}
if ((IMASK & IREG & IRQ_TIMER0) != 0) {
deliverEvent(EVENT_RTC0, 0x1000);
if (s_IRQsAutoAck[IRQ_TIMER0]) IREG &= ~IRQ_TIMER0;
if (s_IRQsAutoAck[IRQ_TIMER0_NUMBER]) IREG &= ~IRQ_TIMER0;
}
if ((IMASK & IREG & IRQ_TIMER1) != 0) {
deliverEvent(EVENT_RTC1, 0x1000);
if (s_IRQsAutoAck[IRQ_TIMER1]) IREG &= ~IRQ_TIMER1;
if (s_IRQsAutoAck[IRQ_TIMER1_NUMBER]) IREG &= ~IRQ_TIMER1;
}
if ((IMASK & IREG & IRQ_TIMER2) != 0) {
// Keeping this copy/paste mistake this way to avoid breaking stuff.
deliverEvent(EVENT_RTC1, 0x1000);
if (s_IRQsAutoAck[IRQ_TIMER2]) IREG &= ~IRQ_TIMER2;
if (s_IRQsAutoAck[IRQ_TIMER2_NUMBER]) IREG &= ~IRQ_TIMER2;
}
if ((IMASK & IREG & IRQ_CONTROLLER) != 0) {
deliverEvent(EVENT_CONTROLLER, 0x1000);
if (s_IRQsAutoAck[IRQ_CONTROLLER]) IREG &= ~IRQ_CONTROLLER;
if (s_IRQsAutoAck[IRQ_CONTROLLER_NUMBER]) IREG &= ~IRQ_CONTROLLER;
}
if ((IMASK & IREG & IRQ_DMA) != 0) {
deliverEvent(EVENT_DMA, 0x1000);
if (s_IRQsAutoAck[IRQ_DMA]) IREG &= ~IRQ_DMA;
if (s_IRQsAutoAck[IRQ_DMA_NUMBER]) IREG &= ~IRQ_DMA;
}
return 0;
}

View file

@ -28,6 +28,7 @@ SOFTWARE.
#include <alloca.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include "common/hardware/cop0.h"
@ -130,7 +131,8 @@ static char s_binaryPath[128];
// the tabulation character ('\t', or character 9) or a space.
// Last but not least, the retail bios will screw things up
// fairly badly if the file isn't terminated using CRLFs.
static void findWordItem(const char *systemCnf, uint32_t *item, const char *name) {
static void findWordItem(const char *systemCnf, void *item_, const char *name) {
uint32_t *item = (uint32_t *)item_;
char c;
const unsigned size = strlen(name);
while (strncmp(systemCnf, name, size) != 0) {
@ -378,7 +380,7 @@ static void boot(char *systemCnfPath, char *binaryPath) {
psxprintf("EXEC:PC0(%08x) T_ADDR(%08x) T_SIZE(%08x)\n", s_binaryInfo.pc, s_binaryInfo.text_addr,
s_binaryInfo.text_size);
psxprintf("boot address : %08x %08x\nExecute !\n\n", s_binaryInfo.pc, s_configuration.stackBase);
s_binaryInfo.stack_start = s_configuration.stackBase;
s_binaryInfo.stack_start = (uintptr_t)s_configuration.stackBase;
s_binaryInfo.stack_size = 0;
// the original format string says S_SIZE(%08), which is obviously wrong...
psxprintf(" S_ADDR(%08x) S_SIZE(%08x)\n", s_configuration.stackBase, 0);

View file

@ -37,7 +37,8 @@ static inline uint32_t hashone(uint32_t a) {
return a;
}
uint32_t patch_hash(const uint32_t* ptr, uint8_t* maskPtr, unsigned len) {
uint32_t patch_hash(const uint32_t* ptr, const void* maskPtr_, unsigned len) {
const uint8_t* maskPtr = (const uint8_t*)maskPtr_;
uint32_t hash = 0x5810d659;
uint32_t mask = 1;

View file

@ -28,4 +28,4 @@ SOFTWARE.
#include <stdint.h>
uint32_t patch_hash(const uint32_t* ptr, uint8_t* mask, unsigned len);
uint32_t patch_hash(const uint32_t* ptr, const void* mask, unsigned len);

View file

@ -99,13 +99,13 @@ enum patch_behavior patch_pad_1_execute(uint32_t *ra) {
ptr <<= 16;
addend = ra[4] & 0xffff;
ptr += addend;
*((uint32_t *)ptr) = patch_startPad;
*((uint32_t *)ptr) = (uint32_t)patch_startPad;
ptr = ra[6] & 0xffff;
ptr <<= 16;
addend = ra[7] & 0xffff;
ptr += addend;
*((uint32_t *)ptr) = patch_stopPad;
*((uint32_t *)ptr) = (uint32_t)patch_stopPad;
ra[2] = 11 | 0x10000000;
ra[3] = 0;

View file

@ -98,13 +98,13 @@ enum patch_behavior patch_pad_2_execute(uint32_t *ra) {
ptr <<= 16;
addend = ra[3] & 0xffff;
ptr += addend;
*((uint32_t *)ptr) = patch_startPad;
*((uint32_t *)ptr) = (uint32_t)patch_startPad;
ptr = ra[4] & 0xffff;
ptr <<= 16;
addend = ra[7] & 0xffff;
ptr += addend;
*((uint32_t *)ptr) = patch_stopPad;
*((uint32_t *)ptr) = (uint32_t)patch_stopPad;
ra[2] = 10 | 0x10000000;
ra[3] = 0;

View file

@ -169,9 +169,9 @@ void patch_hook(uint32_t* ra, enum patch_table table) {
// already patched, bail out
if ((ra[0] == 0) && (ra[1] == 0) && (ra[3] == 0)) return;
uint32_t* hash_mask = NULL;
const uint32_t* hash_mask = NULL;
struct patch* patches = NULL;
const struct patch* patches = NULL;
unsigned size = 0;
char t = 'x';
switch (table) {

View file

@ -116,7 +116,7 @@ enum patch_behavior send_pad_1_execute(uint32_t* ra) {
ptr <<= 16;
addend = ra[8] & 0xffff;
ptr += addend;
*((uint32_t*)ptr) = patch_setPadOutputData;
*((uint32_t*)ptr) = (uint32_t)patch_setPadOutputData;
ra[2] = 15 | 0x10000000;
ra[3] = 0;

View file

@ -115,7 +115,7 @@ enum patch_behavior send_pad_2_execute(uint32_t* ra) {
ptr <<= 16;
addend = ra[7] & 0xffff;
ptr += addend;
*((uint32_t*)ptr) = patch_setPadOutputData;
*((uint32_t*)ptr) = (uint32_t)patch_setPadOutputData;
ra[2] = 12 | 0x10000000;
ra[3] = 0;

View file

@ -60,12 +60,12 @@ static const struct Device s_ttyDevice = {
.write = psxdummy,
.erase = psxdummy,
.undelete = psxdummy,
.firstFile = psxdummy,
.nextFile = psxdummy,
.firstFile = (struct DirEntry * (*)(struct File *, const char *, struct DirEntry *)) psxdummy,
.nextFile = (struct DirEntry * (*)(struct File *, struct DirEntry *)) psxdummy,
.format = psxdummy,
.chdir = psxdummy,
.rename = psxdummy,
.deinit = psxdummy,
.deinit = (void (*)())psxdummy,
.check = psxdummy,
};
@ -76,7 +76,7 @@ static const struct Device s_dummyDevice = {
.flags = 1,
.blockSize = 1,
.desc = "CONSOLE",
.init = psxdummy,
.init = (void (*)()) psxdummy,
.open = psxdummy,
.action = psxdummy,
.close = psxdummy,
@ -85,12 +85,12 @@ static const struct Device s_dummyDevice = {
.write = psxdummy,
.erase = psxdummy,
.undelete = psxdummy,
.firstFile = psxdummy,
.nextFile = psxdummy,
.firstFile = (struct DirEntry * (*)(struct File *, const char *, struct DirEntry *)) psxdummy,
.nextFile = (struct DirEntry * (*)(struct File *, struct DirEntry *)) psxdummy,
.format = psxdummy,
.chdir = psxdummy,
.rename = psxdummy,
.deinit = psxdummy,
.deinit = (void (*)())psxdummy,
.check = psxdummy,
};