Add lseek to sim6502 paravirt

This commit is contained in:
Colin Leroy-Mira
2025-01-01 13:23:03 +01:00
parent ef385c78cc
commit 50cccc2c3a
4 changed files with 101 additions and 2 deletions

View File

@@ -159,6 +159,30 @@ static void PVArgs (CPURegs* Regs)
SetAX (Regs, ArgC);
}
/* Match between standard POSIX whence and cc65 whence. */
static unsigned SEEK_MODE_MATCH[3] = {
SEEK_CUR,
SEEK_END,
SEEK_SET
};
static void PVLseek (CPURegs* Regs)
{
unsigned RetVal;
unsigned Whence = GetAX (Regs);
unsigned Offset = PopParam (4);
unsigned FD = PopParam (2);
Print (stderr, 2, "PVLseek ($%04X, $%08X, $%04X (%d))\n",
FD, Offset, Whence, SEEK_MODE_MATCH[Whence]);
RetVal = lseek(FD, (off_t)Offset, SEEK_MODE_MATCH[Whence]);
Print (stderr, 2, "PVLseek returned %04X\n", RetVal);
SetAX (Regs, RetVal);
}
static void PVOpen (CPURegs* Regs)
@@ -343,6 +367,7 @@ static void PVOSMapErrno (CPURegs* Regs)
static const PVFunc Hooks[] = {
PVLseek,
PVSysRemove,
PVOSMapErrno,
PVOpen,

View File

@@ -44,7 +44,7 @@
#define PARAVIRT_BASE 0xFFF2
#define PARAVIRT_BASE 0xFFF1
/* Lowest address used by a paravirtualization hook */
#define PV_PATH_SIZE 1024