puae 2.5.0b25

This commit is contained in:
Mustafa Tufan 2012-11-13 11:42:24 +02:00
parent 40df5148ca
commit 01e21bd820
12 changed files with 471 additions and 206 deletions

View File

@ -702,7 +702,9 @@ static int command_rawread (int unitnum, uae_u8 *data, int sector, int size, int
struct cdunit *cdu = unitisopen (unitnum);
if (!cdu)
return 0;
int asector = sector;
struct cdtoc *t = findtoc (cdu, &sector);
int ssize = t->size + t->skipsize;
if (!t || t->handle == NULL)
goto end;
@ -713,44 +715,51 @@ static int command_rawread (int unitnum, uae_u8 *data, int sector, int size, int
// 2048 -> 2352
while (size-- > 0) {
memset (data, 0, 16);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize, SEEK_SET);
zfile_fread (data + 16, t->size, 1, t->handle);
encode_l2 (data, sector + 150);
sector++;
asector++;
data += sectorsize;
ret += sectorsize;
}
} else if (sectorsize == 2048 && t->size == 2352) {
// 2352 -> 2048
while (size-- > 0) {
uae_u8 b = 0;
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size + 15, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + 15, SEEK_SET);
zfile_fread (&b, 1, 1, t->handle);
if (b == 2) // MODE2?
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size + 24, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + 24, SEEK_SET);
zfile_fread (data, sectorsize, 1, t->handle);
sector++;
asector++;
data += sectorsize;
ret += sectorsize;
}
} else if (sectorsize == 2336 && t->size == 2352) {
// 2352 -> 2336
while (size-- > 0) {
uae_u8 b = 0;
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size + 15, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + 15, SEEK_SET);
zfile_fread (&b, 1, 1, t->handle);
if (b != 2 && b != 0) // MODE0 or MODE2 only allowed
return 0;
zfile_fread (data, sectorsize, 1, t->handle);
sector++;
asector++;
data += sectorsize;
ret += sectorsize;
}
} else if (sectorsize == t->size) {
// no change
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize, SEEK_SET);
zfile_fread (data, sectorsize, size, t->handle);
sector += size;
asector += size;
ret = size;
}
cdu->cd_last_pos = sector;
ret = sectorsize * size;
cdu->cd_last_pos = asector;
} else {
@ -777,7 +786,7 @@ static int command_rawread (int unitnum, uae_u8 *data, int sector, int size, int
goto end;
}
for (unsigned int i = 0; i < size; i++) {
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize, SEEK_SET);
zfile_fread (data, t->size, 1, t->handle);
uae_u8 *p = data + t->size;
if (subs) {
@ -812,24 +821,25 @@ static int command_read (int unitnum, uae_u8 *data, int sector, int size)
return 0;
struct cdtoc *t = findtoc (cdu, &sector);
int ssize = t->size + t->skipsize;
if (!t || t->handle == NULL)
return 0;
cdda_stop (cdu);
if (t->size == 2048) {
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize, SEEK_SET);
zfile_fread (data, size, 2048, t->handle);
sector += size;
} else {
while (size-- > 0) {
if (t->size == 2352) {
uae_u8 b = 0;
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size + 15, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + 15, SEEK_SET);
zfile_fread (&b, 1, 1, t->handle);
if (b == 2) // MODE2?
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size + 24, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + 24, SEEK_SET);
} else {
zfile_fseek (t->handle, t->offset + (uae_u64)sector * t->size + 16, SEEK_SET);
zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + 16, SEEK_SET);
}
zfile_fread (data, 1, 2048, t->handle);
data += 2048;
@ -1071,6 +1081,9 @@ static int parsemds (struct cdunit *cdu, struct zfile *zmds, const TCHAR *img)
t->offset = tb->start_offset;
t->size = tb->sector_size;
if (point >= 100)
continue;
if (footer) {
TCHAR *fname = NULL;
if (footer->widechar_filename == 0)
@ -1099,10 +1112,9 @@ static int parsemds (struct cdunit *cdu, struct zfile *zmds, const TCHAR *img)
t->subhandle = zfile_dup (t->handle);
t->skipsize = SUB_CHANNEL_SIZE;
t->size -= SUB_CHANNEL_SIZE;
if ((t->ctrl & 0x0c) != 4)
t->enctype = AUDENC_PCM;
}
if ((t->ctrl & 0x0c) != 4)
t->enctype = AUDENC_PCM;
}
}

View File

@ -443,8 +443,7 @@ bool calc(const TCHAR *input, double *outval)
bool iscalcformula (const TCHAR *formula)
{
unsigned int i;
for (i = 0; i < _tcslen (formula); i++) {
for (unsigned int i = 0; i < _tcslen (formula); i++) {
TCHAR c = formula[i];
if (is_operator (c))
return true;

View File

@ -2696,18 +2696,17 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
return 1;
#endif
if (cfgfile_strval (option, value, _T("chipset_compatible"), &p->cs_compatible, cscompa, 0)
|| cfgfile_strval (option, value, _T("rtc"), &p->cs_rtc, rtctype, 0)
|| cfgfile_strval (option, value, _T("ciaatod"), &p->cs_ciaatod, ciaatodmode, 0)
|| cfgfile_strval (option, value, _T("ide"), &p->cs_ide, idemode, 0)
|| cfgfile_strval (option, value, _T("scsi"), &p->scsi, scsimode, 0)
|| cfgfile_strval (option, value, _T("collision_level"), &p->collision_level, collmode, 0)
|| cfgfile_strval (option, value, _T("parallel_matrix_emulation"), &p->parallel_matrix_emulation, epsonprinter, 0)
|| cfgfile_strval (option, value, _T("monitoremu"), &p->monitoremu, specialmonitors, 0)
|| cfgfile_strval (option, value, _T("waiting_blits"), &p->waiting_blits, waitblits, 0)
|| cfgfile_strval (option, value, _T("floppy_auto_extended_adf"), &p->floppy_auto_ext2, autoext2, 0)
|| cfgfile_strboolval (option, value, _T("comp_flushmode"), &p->comp_hardflush, flushmode, 0))
return 1;
if (cfgfile_strval (option, value, _T("rtc"), &p->cs_rtc, rtctype, 0)
|| cfgfile_strval (option, value, _T("ciaatod"), &p->cs_ciaatod, ciaatodmode, 0)
|| cfgfile_strval (option, value, _T("ide"), &p->cs_ide, idemode, 0)
|| cfgfile_strval (option, value, _T("scsi"), &p->scsi, scsimode, 0)
|| cfgfile_strval (option, value, _T("collision_level"), &p->collision_level, collmode, 0)
|| cfgfile_strval (option, value, _T("parallel_matrix_emulation"), &p->parallel_matrix_emulation, epsonprinter, 0)
|| cfgfile_strval (option, value, _T("monitoremu"), &p->monitoremu, specialmonitors, 0)
|| cfgfile_strval (option, value, _T("waiting_blits"), &p->waiting_blits, waitblits, 0)
|| cfgfile_strval (option, value, _T("floppy_auto_extended_adf"), &p->floppy_auto_ext2, autoext2, 0)
|| cfgfile_strboolval (option, value, _T("comp_flushmode"), &p->comp_hardflush, flushmode, 0))
return 1;
if (cfgfile_path_mp (option, value, _T("kickstart_rom_file"), p->romfile, sizeof p->romfile / sizeof (TCHAR), &p->path_rom)
|| cfgfile_path_mp (option, value, _T("kickstart_ext_rom_file"), p->romextfile, sizeof p->romextfile / sizeof (TCHAR), &p->path_rom)

View File

@ -298,29 +298,37 @@ static int readregx (TCHAR **c, uae_u32 *valp)
return 1;
}
static uae_u32 readbinx (TCHAR **c)
static bool readbinx (TCHAR **c, uae_u32 *valp)
{
uae_u32 val = 0;
bool first = true;
ignore_ws (c);
for (;;) {
TCHAR nc = **c;
if (nc != '1' && nc != '0')
if (nc != '1' && nc != '0') {
if (first)
return false;
break;
}
first = false;
(*c)++;
val <<= 1;
if (nc == '1')
val |= 1;
}
return val;
*valp = val;
return true;
}
static uae_u32 readhexx (TCHAR **c)
static bool readhexx (TCHAR **c, uae_u32 *valp)
{
uae_u32 val = 0;
TCHAR nc;
ignore_ws (c);
if (!isxdigit (peekchar (c)))
return false;
while (isxdigit (nc = **c)) {
(*c)++;
val *= 16;
@ -331,10 +339,11 @@ static uae_u32 readhexx (TCHAR **c)
val += nc - 'A' + 10;
}
}
return val;
*valp = val;
return true;
}
static uae_u32 readintx (TCHAR **c)
static bool readintx (TCHAR **c, uae_u32 *valp)
{
uae_u32 val = 0;
TCHAR nc;
@ -343,16 +352,19 @@ static uae_u32 readintx (TCHAR **c)
ignore_ws (c);
if (**c == '-')
negative = 1, (*c)++;
if (!isdigit (peekchar (c)))
return false;
while (isdigit (nc = **c)) {
(*c)++;
val *= 10;
val += nc - '0';
}
return val * (negative ? -1 : 1);
*valp = val * (negative ? -1 : 1);
return true;
}
static int checkvaltype (TCHAR **c, uae_u32 *val)
static int checkvaltype2 (TCHAR **c, uae_u32 *val, TCHAR def)
{
TCHAR nc;
@ -360,37 +372,38 @@ static int checkvaltype (TCHAR **c, uae_u32 *val)
nc = _totupper (**c);
if (nc == '!') {
(*c)++;
*val = readintx (c);
return 1;
return readintx (c, val) ? 1 : 0;
}
if (nc == '$') {
(*c)++;
*val = readhexx (c);
return 1;
return readhexx (c, val) ? 1 : 0;
}
if (nc == '0' && _totupper ((*c)[1]) == 'X') {
(*c)+= 2;
*val = readhexx (c);
return 1;
return readhexx (c, val) ? 1 : 0;
}
if (nc == '%') {
(*c)++;
*val = readbinx (c);
return 1;
return readbinx (c, val) ? 1: 0;
}
if (nc >= 'A' && nc <= 'Z' && nc != 'A' && nc != 'D') {
if (readregx (c, val))
return 1;
}
if (def == '!') {
return readintx (c, val) ? -1 : 0;
return -1;
} else if (def == '$') {
return readhexx (c, val) ? -1 : 0;
} else if (def == '%') {
return readbinx (c, val) ? -1 : 0;
}
return 0;
}
static int readsize (int val, TCHAR **c)
{
if ((*c)[0] == '.') {
(*c)++;
TCHAR cc = _totupper ((*c)[0]);
(*c)++;
TCHAR cc = _totupper (readchar(c));
if (cc == 'B')
return 1;
if (cc == 'W')
@ -399,46 +412,97 @@ static int readsize (int val, TCHAR **c)
return 3;
if (cc == 'L')
return 4;
return 0;
}
static int checkvaltype (TCHAR **cp, uae_u32 *val, int *size, TCHAR def)
{
TCHAR form[256], *p;
bool gotop = false;
double out;
form[0] = 0;
*size = 0;
p = form;
for (;;) {
uae_u32 v;
if (!checkvaltype2 (cp, &v, def))
return 0;
*val = v;
// stupid but works!
_stprintf(p, _T("%u"), v);
p += _tcslen (p);
if (peekchar (cp) == '.') {
readchar (cp);
*size = readsize (v, cp);
}
if (!isoperator (cp))
break;
gotop = true;
*p++= readchar (cp);
*p = 0;
}
if (!gotop) {
if (*size == 0) {
uae_s32 v = (uae_s32)(*val);
if (v > 255 || v < -127) {
*size = 2;
} else if (v > 65535 || v < -32767) {
*size = 4;
} else {
*size = 1;
}
}
if (val > 255 || val < -127)
return 2;
if (val > 65535 || val < -32767)
return 4;
return 1;
}
if (calc (form, &out)) {
*val = (uae_u32)out;
if (*size == 0) {
uae_s32 v = (uae_s32)(*val);
if (v > 255 || v < -127) {
*size = 2;
} else if (v > 65535 || v < -32767) {
*size = 4;
} else {
*size = 1;
}
}
return 1;
}
return 0;
}
static uae_u32 readnum (TCHAR **c, int *size, TCHAR def)
{
uae_u32 val;
if (checkvaltype (c, &val, size, def))
return val;
return 0;
}
static uae_u32 readint (TCHAR **c)
{
uae_u32 val;
if (checkvaltype (c, &val))
return val;
return readintx (c);
int size;
return readnum (c, &size, '!');
}
static uae_u32 readhex (TCHAR **c)
{
uae_u32 val;
if (checkvaltype (c, &val))
return val;
return readhexx (c);
}
static uae_u32 readint_s (TCHAR **c, int *size)
{
uae_u32 val = readint (c);
*size = readsize (val, c);
return val;
}
static uae_u32 readhex_s (TCHAR **c, int *size)
{
uae_u32 val = readhex (c);
*size = readsize (val, c);
return val;
int size;
return readnum (c, &size, '$');
}
static uae_u32 readbin (TCHAR **c)
{
uae_u32 val;
if (checkvaltype (c, &val))
return val;
return readbinx (c);
int size;
return readnum (c, &size, '%');
}
static uae_u32 readint_2 (TCHAR **c, int *size)
{
return readnum (c, size, '!');
}
static uae_u32 readhex_2 (TCHAR **c, int *size)
{
return readnum (c, size, '$');
}
static int next_string (TCHAR **c, TCHAR *out, int max, int forceupper)
@ -492,8 +556,12 @@ int notinrom (void)
static uae_u32 lastaddr (void)
{
if (currprefs.z3fastmem2_size)
return z3fastmem2_start + currprefs.z3fastmem2_size;
if (currprefs.z3fastmem_size)
return z3fastmem_start + currprefs.z3fastmem_size;
if (currprefs.z3chipmem_size)
return z3chipmem_start + currprefs.z3chipmem_size;
if (currprefs.mbresmem_high_size)
return a3000hmem_start + currprefs.mbresmem_high_size;
if (currprefs.mbresmem_low_size)
@ -514,9 +582,29 @@ static uaecptr nextaddr2 (uaecptr addr, int *next)
*next = -1;
return 0xffffffff;
}
prev = currprefs.z3fastmem_start;
size = currprefs.z3fastmem_size;
prev = currprefs.z3fastmem_start + currprefs.z3fastmem_size;
size = currprefs.z3fastmem2_size;
if (currprefs.z3fastmem_size) {
prevx = prev;
sizex = size;
size = currprefs.z3fastmem_size;
prev = z3fastmem_start;
if (addr == prev + size) {
*next = prevx + sizex;
return prevx;
}
}
if (currprefs.z3chipmem_size) {
prevx = prev;
sizex = size;
size = currprefs.z3chipmem_size;
prev = z3chipmem_start;
if (addr == prev + size) {
*next = prevx + sizex;
return prevx;
}
}
if (currprefs.mbresmem_high_size) {
sizex = size;
prevx = prev;
@ -571,6 +659,7 @@ static uaecptr nextaddr2 (uaecptr addr, int *next)
static uaecptr nextaddr (uaecptr addr, uaecptr last, uaecptr *end)
{
static uaecptr old;
uaecptr paddr = addr;
int next;
if (last && 0) {
@ -588,6 +677,11 @@ static uaecptr nextaddr (uaecptr addr, uaecptr last, uaecptr *end)
addr = nextaddr2 (addr + 1, &next);
if (end)
*end = next;
if (old != next) {
if (addr != 0xffffffff)
console_out_f (_T("Scanning.. %08x - %08x (%s)\n"), addr & 0xffffff00, next, get_mem_bank (addr).name);
old = next;
}
#if 0
if (next && addr != 0xffffffff) {
uaecptr xa = addr;
@ -624,7 +718,7 @@ uaecptr dumpmem2 (uaecptr addr, TCHAR *out, int osize)
for (i = 0; i < cols; i++) {
uae_u8 b1, b2;
b1 = b2 = 0;
if (safe_addr(addr, 2)) {
if (safe_addr (addr, 1)) {
b1 = get_byte (addr + 0);
b2 = get_byte (addr + 1);
_stprintf (out + 9 + i * 5, _T("%02X%02X "), b1, b2);
@ -1023,6 +1117,8 @@ static void decode_dma_record (int hpos, int vpos, int toggle, bool logfile)
l3[cl2++] = 'p';
if (dr->evt & DMA_EVENT_COPPERWAKE)
l3[cl2++] = 'W';
if (dr->evt & DMA_EVENT_COPPERWANTED)
l3[cl2++] = 'c';
if (dr->evt & DMA_EVENT_CPUIRQ)
l3[cl2++] = 'I';
if (dr->evt & DMA_EVENT_INTREQ)
@ -1381,6 +1477,10 @@ static void deepcheatsearch (TCHAR **c)
break;
addrcnt += 2;
}
if (iscancel (65536)) {
console_out_f (_T("Aborted at %08X\n"), addr);
break;
}
}
console_out_f (_T("%d addresses found\n"), cnt);
@ -1437,7 +1537,7 @@ static void cheatsearch (TCHAR **c)
return;
}
if (first)
val = readint_s (c, &size);
val = readint_2 (c, &size);
else
val = readint (c);
@ -1481,6 +1581,10 @@ static void cheatsearch (TCHAR **c)
}
}
memcnt++;
if (iscancel (65536)) {
console_out_f (_T("Aborted at %08X\n"), addr);
break;
}
}
if (!first) {
while (prevmemcnt < memcnt) {
@ -1750,6 +1854,8 @@ uae_u8 *save_debug_memwatch (int *len, uae_u8 *dstptr)
save_u32 (m->modval);
save_u32 (m->val_mask);
save_u32 (m->val_size);
save_u32 (m->val);
save_u32 (m->pc);
save_store_size ();
}
*len = dst - dstbak;
@ -1775,6 +1881,8 @@ uae_u8 *restore_debug_memwatch (uae_u8 *src)
m->modval = restore_u32 ();
m->val_mask = restore_u32 ();
m->val_size = restore_u32 ();
m->val = restore_u32 ();
m->pc = restore_u32 ();
restore_store_size ();
}
return src;
@ -2351,7 +2459,7 @@ static void memwatch (TCHAR **c)
} else if (_totupper (**c) == 'C') {
mwn->mustchange = 1;
} else {
mwn->val = readhex_s (c, &mwn->val_size);
mwn->val = readhex_2 (c, &mwn->val_size);
mwn->val_enabled = 1;
}
}
@ -2371,20 +2479,49 @@ static void writeintomem (TCHAR **c)
ignore_ws(c);
addr = readhex (c);
ignore_ws(c);
val = readhex_s (c, &len);
if (len == 4) {
put_long (addr, val);
cc = 'L';
} else if (len == 2) {
put_word (addr, val);
cc = 'W';
ignore_ws (c);
if (!more_params (c))
return;
cc = peekchar (c);
if (cc == '\'' || cc == '\"') {
next_char (c);
while (more_params (c)) {
TCHAR str[2];
char *astr;
cc = next_char (c);
if (cc == '\'' || cc == '\"')
break;
str[0] = cc;
str[1] = 0;
astr = ua (str);
put_byte (addr, astr[0]);
xfree (astr);
addr++;
}
} else {
put_byte (addr, val);
cc = 'B';
for (;;) {
ignore_ws (c);
if (!more_params (c))
break;
val = readhex_2 (c, &len);
if (len == 4) {
put_long (addr, val);
cc = 'L';
} else if (len == 2) {
put_word (addr, val);
cc = 'W';
} else if (len == 1) {
put_byte (addr, val);
cc = 'B';
} else {
break;
}
console_out_f (_T("Wrote %X (%u) at %08X.%c\n"), val, val, addr, cc);
addr += len;
}
}
console_out_f (_T("Wrote %X (%u) at %08X.%c\n"), val, val, addr, cc);
}
static uae_u8 *dump_xlate (uae_u32 addr)
@ -2922,6 +3059,10 @@ static void searchmem (TCHAR **cc)
break;
}
}
if (iscancel (65536)) {
console_out_f (_T("Aborted at %08X\n"), addr);
break;
}
}
if (!got)
console_out (_T("nothing found"));
@ -3213,6 +3354,10 @@ static void find_ea (TCHAR **inptr)
break;
}
}
if (iscancel (65536)) {
console_out_f (_T("Aborted at %08X\n"), addr);
break;
}
}
}
}
@ -3685,7 +3830,7 @@ void debug (void)
int bp = 0;
pc = munge24 (m68k_getpc ());
opcode = (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) ? regs.ir : get_word (pc);
opcode = currprefs.cpu_model < 68020 && (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) ? regs.ir : get_word (pc);
for (i = 0; i < BREAKPOINT_TOTAL; i++) {
if (!bpnodes[i].enabled)
@ -3774,6 +3919,7 @@ void debug (void)
inputdevice_unacquire ();
pause_sound ();
setmouseactive (0);
do_skip = 0;
skipaddr_start = 0xffffffff;
skipaddr_end = 0xffffffff;

View File

@ -2242,6 +2242,11 @@ bool disk_creatediskfile (const TCHAR *name, int type, drive_type adftype, const
tracks /= 2;
}
if (copyfrom) {
pos = zfile_ftell (copyfrom);
zfile_fseek (copyfrom, 0, SEEK_SET);
}
f = zfile_fopen (name, _T("wb"), 0);
chunk = xmalloc (uae_u8, size);
if (f && chunk) {
@ -2287,11 +2292,15 @@ bool disk_creatediskfile (const TCHAR *name, int type, drive_type adftype, const
}
for (i = 0; i < tracks; i++) {
memset (chunk, 0, size);
if (dodos) {
if (i == 0)
floppy_get_bootblock (chunk, ffs, bootable);
else if (i == 80)
floppy_get_rootblock (chunk, 80 * 11 * ddhd, disk_name, adftype);
if (copyfrom) {
zfile_fread (chunk, 11 * ddhd, 512, copyfrom);
} else {
if (dodos) {
if (i == 0)
floppy_get_bootblock (chunk, ffs, bootable);
else if (i == 80)
floppy_get_rootblock (chunk, 80 * 11 * ddhd, disk_name, adftype);
}
}
zfile_fwrite (chunk, l, 1, f);
}
@ -2300,6 +2309,8 @@ bool disk_creatediskfile (const TCHAR *name, int type, drive_type adftype, const
}
xfree (chunk);
zfile_fclose (f);
if (copyfrom)
zfile_fseek (copyfrom, pos, SEEK_SET);
if (f)
DISK_history_add (name, -1, HISTORY_FLOPPY, 1);
return ok;

View File

@ -2642,9 +2642,11 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context)
put_byte (unit->volume + 44, 0);
if (!uinfo->wasisempty && !uinfo->unknown_media) {
int isvirtual = unit->volflags & (MYVOLUMEINFO_ARCHIVE | MYVOLUMEINFO_CDFS);
/* Set volume if non-empty */
set_volume_name (unit, ctime);
fsdb_clean_dir (&unit->rootnode);
if (!isvirtual)
fsdb_clean_dir (&unit->rootnode);
}
put_long (unit->volume + 8, unit->port);
@ -3353,9 +3355,9 @@ static void
memset (&statbuf, 0, sizeof statbuf);
/* No error checks - this had better work. */
/* if (unit->volflags & MYVOLUMEINFO_ARCHIVE)
zfile_stat_archive (aino->nname, &statbuf);
ok = zfile_stat_archive (aino->nname, &statbuf) != 0;
else if (unit->volflags & MYVOLUMEINFO_CDFS)
isofs_stat (unit->ui.cdfs_superblock, aino->uniq_external, &statbuf);
ok = isofs_stat (unit->ui.cdfs_superblock, aino->uniq_external, &statbuf);
else*/
stat (aino->nname, &statbuf);
@ -4089,7 +4091,7 @@ static void populate_directory (Unit *unit, a_inode *base)
ok = isofs_readdir (d->isod, fn, &uniq);
else*/
ok = readdir (d->od);
} while (ok /*&& !d->isarch*/ && fsdb_name_invalid (ok->d_name));
} while (ok /*&& d->fstype == FS_DIRECTORY*/ && fsdb_name_invalid (ok->d_name));
if (!ok)
break;
/* This calls init_child_aino, which will notice that the parent is
@ -5649,13 +5651,7 @@ static int handle_packet (Unit *unit, dpacket pck, uae_u32 msg)
uae_s32 type = GET_PCK_TYPE (pck);
PUT_PCK_RES2 (pck, 0);
#if 0
if (unit->cdfs_superblock)
write_log(_T("unit=%x packet=%d\n"), unit, type);
#endif
#if TRACING_ENABLED > 1
write_log(_T("unit=%x packet=%d\n"), unit, type);
#endif
TRACE((_T("unit=%x packet=%d\n"), unit, type));
if (unit->inhibited && filesys_isvolume (unit)
&& type != ACTION_INHIBIT && type != ACTION_MORE_CACHE
&& type != ACTION_DISK_INFO) {
@ -5736,49 +5732,58 @@ static int handle_packet (Unit *unit, dpacket pck, uae_u32 msg)
}
#ifdef UAE_FILESYS_THREADS
static int filesys_iteration(UnitInfo *ui)
{
dpacket pck;
uaecptr msg;
uae_u32 morelocks;
pck = read_comm_pipe_u32_blocking (ui->unit_pipe);
msg = read_comm_pipe_u32_blocking (ui->unit_pipe);
morelocks = (uae_u32)read_comm_pipe_int_blocking (ui->unit_pipe);
if (ui->reset_state == FS_GO_DOWN) {
if (pck != 0)
return 1;
/* Death message received. */
uae_sem_post (&ui->reset_sync_sem);
/* Die. */
return 0;
}
put_long (get_long (morelocks), get_long (ui->self->locklist));
put_long (ui->self->locklist, morelocks);
int ret = handle_packet (ui->self, pck, msg);
if (!ret) {
PUT_PCK_RES1 (pck, DOS_FALSE);
PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN);
}
if (ret >= 0) {
/* Mark the packet as processed for the list scan in the assembly code. */
put_long (msg + 4, 0xffffffff);
}
/* Acquire the message lock, so that we know we can safely send the message. */
ui->self->cmds_sent++;
/* The message is sent by our interrupt handler, so make sure an interrupt happens. */
do_uae_int_requested ();
/* Send back the locks. */
if (get_long (ui->self->locklist) != 0)
write_comm_pipe_int (ui->back_pipe, (int)(get_long (ui->self->locklist)), 0);
put_long (ui->self->locklist, 0);
return 1;
}
static void *filesys_thread (void *unit_v)
{
UnitInfo *ui = (UnitInfo *)unit_v;
uae_set_thread_priority (NULL, 1);
for (;;) {
dpacket pck;
uaecptr msg;
uae_u32 morelocks;
pck = read_comm_pipe_u32_blocking (ui->unit_pipe);
msg = read_comm_pipe_u32_blocking (ui->unit_pipe);
morelocks = (uae_u32)read_comm_pipe_int_blocking (ui->unit_pipe);
if (ui->reset_state == FS_GO_DOWN) {
if (pck != 0)
continue;
/* Death message received. */
uae_sem_post (&ui->reset_sync_sem);
/* Die. */
if (!filesys_iteration (ui)) {
return 0;
}
put_long (get_long (morelocks), get_long (ui->self->locklist));
put_long (ui->self->locklist, morelocks);
int ret = handle_packet (ui->self, pck, msg);
if (!ret) {
PUT_PCK_RES1 (pck, DOS_FALSE);
PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN);
}
if (ret >= 0) {
/* Mark the packet as processed for the list scan in the assembly code. */
put_long (msg + 4, 0xffffffff);
}
/* Acquire the message lock, so that we know we can safely send the message. */
ui->self->cmds_sent++;
/* The message is sent by our interrupt handler, so make sure an interrupt happens. */
do_uae_int_requested ();
/* Send back the locks. */
if (get_long (ui->self->locklist) != 0)
write_comm_pipe_int (ui->back_pipe, (int)(get_long (ui->self->locklist)), 0);
put_long (ui->self->locklist, 0);
}
return 0;
}
@ -6705,15 +6710,87 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context)
int unit_no = no & 65535;
int sub_no = no >> 16;
int iscd = (m68k_dreg (regs, 6) & 0x80000000) != 0 || uip[unit_no].unit_type == UNIT_CDFS;
int type;
uaecptr parmpacket = m68k_areg (regs, 0);
gui_flicker_led (LED_HD, unit_no, -1);
int type = is_hardfile (unit_no);
if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE) {
/* RDB hardfile */
uip[unit_no].devno = unit_no;
return rdb_mount (&uip[unit_no], unit_no, sub_no, parmpacket);
}
if (iscd) {
TCHAR *cdname = NULL;
uaecptr cdname_amiga;
int cd_unit_no = unit_no - cd_unit_offset;
if (sub_no)
return -2;
type = FILESYS_CD;
if (USE_CDFS == 2) {
get_new_device (type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, cd_unit_no);
cdname_amiga = uip[unit_no].devname_amiga;
uip[unit_no].devno = unit_no;
type = FILESYS_VIRTUAL;
} else {
get_new_device (type, parmpacket, &cdname, &cdname_amiga, cd_unit_no);
}
gui_flicker_led (LED_CD, cd_unit_no, -1);
#ifdef SCSI
write_log (_T("Mounting uaescsi.device %d: (%d)\n"), cd_unit_no, unit_no);
put_long (parmpacket + 0, cdname_amiga);
put_long (parmpacket + 4, cdfs_devname);
put_long (parmpacket + 8, cd_unit_no);
put_long (parmpacket + 12, 0); /* Device flags */
put_long (parmpacket + 16, 19); /* Env. size */
put_long (parmpacket + 20, 2048 >> 2); /* longwords per block */
put_long (parmpacket + 24, 0); /* unused */
put_long (parmpacket + 28, 1); /* heads */
put_long (parmpacket + 32, 1); /* sectors per block */
put_long (parmpacket + 36, 1); /* sectors per track */
put_long (parmpacket + 40, 0); /* reserved blocks */
put_long (parmpacket + 44, 0); /* unused */
put_long (parmpacket + 48, 0); /* interleave */
put_long (parmpacket + 52, 0); /* lowCyl */
put_long (parmpacket + 56, 0); /* hiCyl */
put_long (parmpacket + 60, 50); /* Number of buffers */
put_long (parmpacket + 64, 1); /* Buffer mem type */
put_long (parmpacket + 68, 0x7FFFFFFE); /* largest transfer */
put_long (parmpacket + 72, 0x7FFFFFFE); /* addrressMask (?) */
put_long (parmpacket + 76, scsi_get_cd_drive_media_mask () & (1 << cd_unit_no) ? -127 : -128); /* bootPri */
put_long (parmpacket + 80, CDFS_DOSTYPE | (((cd_unit_no / 10) + '0') << 8) | ((cd_unit_no % 10) + '0'));
put_long (parmpacket + 84, 0); /* baud */
put_long (parmpacket + 88, cdfs_control);
put_long (parmpacket + 92, 0); /* bootblocks */
#if USE_CDFS == 1
uaecptr fsres = get_long (parmpacket + PP_FSRES);
bool cdfs = false;
if (fsres) {
uaecptr fsnode = get_long (fsres + 18);
while (get_long (fsnode)) {
if (get_long (fsnode + 14) == CDFS_DOSTYPE) {
cdfs = true;
break;
}
fsnode = get_long (fsnode);
}
} else {
write_log (_T("CDFS: FileSystem.resource not found, this shouldn't happen!\n"));
cdfs = true;
}
if (!cdfs) {
put_long (parmpacket + PP_FSSIZE, cdfs_handler_len);
addfakefilesys (parmpacket, CDFS_DOSTYPE);
}
#endif
#endif
return type;
} else {
gui_flicker_led (LED_HD, unit_no, -1);
type = is_hardfile (unit_no);
if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE) {
/* RDB hardfile */
uip[unit_no].devno = unit_no;
return rdb_mount (&uip[unit_no], unit_no, sub_no, parmpacket);
}
if (sub_no)
return -2;
write_log (_T("Mounting uaehf.device %d (%d):\n"), unit_no, sub_no);
@ -6758,7 +6835,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context)
if (uip[unit_no].bootpri < -128)
return -1; /* do not mount */
return type;
}
}
static uae_u32 REGPARAM2 mousehack_done (TrapContext *context)
@ -7233,7 +7310,7 @@ static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src)
missing = 1;
} else {
uae_s64 s;
s = fs_lseek64 (k->fd, 0, SEEK_END);
s = fs_fsize64 (k->fd);
if (s != savedsize)
write_log (_T("FS: restored file '%s' size changed! orig=%llu, now=%lld!!\n"), p, savedsize, s);
if (k->file_pos > s) {
@ -7396,10 +7473,9 @@ static uae_u8 *save_key (uae_u8 *dst, Key *k)
save_u32 ((uae_u32)k->file_pos);
save_u32 (k->createmode);
save_u32 (k->dosmode);
size = fs_lseek (k->fd, 0, SEEK_END);
size = fs_fsize (k->fd);
save_u32 ((uae_u32)size);
save_u64 (k->aino->uniq);
fs_lseek (k->fd, k->file_pos, SEEK_SET);
save_string (fn);
save_u64 (k->file_pos);
save_u64 (size);

View File

@ -76,6 +76,8 @@ static FILE *get_fsdb (a_inode *dir, const TCHAR *mode)
TCHAR *n;
FILE *f;
if (!dir->nname)
return NULL;
n = build_nname (dir->nname, FSDB_FILE);
f = _tfopen (n, mode);
xfree (n);
@ -84,6 +86,8 @@ static FILE *get_fsdb (a_inode *dir, const TCHAR *mode)
static void kill_fsdb (a_inode *dir)
{
if (!dir->nname)
return;
TCHAR *n = build_nname (dir->nname, FSDB_FILE);
_wunlink (n);
xfree (n);
@ -116,6 +120,8 @@ void fsdb_clean_dir (a_inode *dir)
FILE *f;
off_t pos1 = 0, pos2;
if (!dir->nname)
return;
n = build_nname (dir->nname, FSDB_FILE);
f = _tfopen (n, _T("r+b"));
if (f == 0) {
@ -141,7 +147,7 @@ void fsdb_clean_dir (a_inode *dir)
xfree (n);
}
static a_inode *aino_from_buf (a_inode *base, char *buf, long off)
static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, long off)
{
uae_u32 mode;
a_inode *aino = xcalloc (a_inode, 1);

View File

@ -13,6 +13,9 @@
#include "fsdb.h"
#define NUM_EVILCHARS 7
static TCHAR evilchars[NUM_EVILCHARS] = { '\\', '*', '?', '\"', '<', '>', '|' };
#define TRACING_ENABLED 0
#if TRACING_ENABLED
#define TRACE(x) do { write_log x; } while(0)
@ -143,41 +146,53 @@ int fsdb_mode_supported (const a_inode *aino)
* native FS. Return zero if that is not possible. */
int fsdb_mode_representable_p (const a_inode *aino, int amigaos_mode)
{
int mask = amigaos_mode ^ 15;
int mask = amigaos_mode ^ 15;
if (0 && aino->dir)
return amigaos_mode == 0;
if (0 && aino->dir)
return amigaos_mode == 0;
if (mask & A_FIBF_SCRIPT) /* script */
return 0;
if ((mask & 15) == 15) /* xxxxRWED == OK */
return 1;
if (!(mask & A_FIBF_EXECUTE)) /* not executable */
return 0;
if (!(mask & A_FIBF_READ)) /* not readable */
return 0;
if ((mask & 15) == (A_FIBF_READ | A_FIBF_EXECUTE)) /* ----RxEx == ReadOnly */
return 1;
return 0;
if (mask & A_FIBF_SCRIPT) /* script */
return 0;
if ((mask & 15) == 15) /* xxxxRWED == OK */
return 1;
if (!(mask & A_FIBF_EXECUTE)) /* not executable */
return 0;
if (!(mask & A_FIBF_READ)) /* not readable */
return 0;
if ((mask & 15) == (A_FIBF_READ | A_FIBF_EXECUTE)) /* ----RxEx == ReadOnly */
return 1;
return 0;
}
char *fsdb_create_unique_nname (a_inode *base, const char *suggestion)
{
char tmp[256] = "__uae___";
strncat (tmp, suggestion, 240);
for (;;) {
TCHAR *c;
TCHAR tmp[256] = "__uae___";
int i;
char *p = build_nname (base->nname, tmp);
if (access (p, R_OK) < 0 && errno == ENOENT) {
printf ("unique name: %s\n", p);
return p;
}
free (p);
/* tmpnam isn't reentrant and I don't really want to hack configure
* right now to see whether tmpnam_r is available... */
for (i = 0; i < 8; i++) {
tmp[i] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[uaerand () % 63];
}
}
strncat (tmp, suggestion, 240);
/* replace the evil ones... */
for (i = 0; i < NUM_EVILCHARS; i++)
while ((c = _tcschr (tmp, evilchars[i])) != 0)
*c = '_';
while ((c = _tcschr (tmp, '.')) != 0)
*c = '_';
while ((c = _tcschr (tmp, ' ')) != 0)
*c = '_';
for (;;) {
TCHAR *p = build_nname (base->nname, tmp);
if (!fsdb_exists (p)) {
write_log (_T("unique name: %s\n"), p);
return p;
}
xfree (p);
/* tmpnam isn't reentrant and I don't really want to hack configure
* right now to see whether tmpnam_r is available... */
for (i = 0; i < 8; i++) {
tmp[i+8] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[rand () % 63];
}
}
}

View File

@ -93,8 +93,11 @@ int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
#include <proto/exec.h>
#include <proto/dos.h>
int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
int get_fs_usage (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp)
{
// TCHAR buf2[MAX_DPATH];
// ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
struct InfoData *info = (struct InfoData *)AllocVec(sizeof *info, MEMF_ANY);
int result = -1;
@ -134,13 +137,8 @@ int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
if (device >0) {
fs_info info;
if (fs_stat_dev (device, &info) == 0) {
fsp->fsu_blocks = adjust_blocks (info.total_blocks,
info.block_size,
512);
fsp->fsu_bfree = fsp->fsu_bavail =
adjust_blocks (info.free_blocks,
info.block_size,
512);
fsp->fsu_blocks = adjust_blocks (info.total_blocks, info.block_size, 512);
fsp->fsu_bfree = fsp->fsu_bavail = adjust_blocks (info.free_blocks, info.block_size, 512);
fsp->fsu_files = info.total_nodes;
fsp->fsu_ffree = info.free_nodes;
@ -199,11 +197,7 @@ int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
Return the actual number of bytes read, zero for EOF, or negative
for an error. */
int
safe_read (desc, ptr, len)
int desc;
TCHAR *ptr;
int len;
int safe_read (int desc, TCHAR *ptr, int len)
{
int n_chars;
@ -230,11 +224,7 @@ int
Return 0 if successful, -1 if not. When returning -1, ensure that
ERRNO is either a system error value, or zero if DISK is NULL
on a system that requires a non-NULL value. */
int
get_fs_usage (path, disk, fsp)
const TCHAR *path;
const TCHAR *disk;
struct fs_usage *fsp;
int get_fs_usage (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp)
{
#ifdef STAT_STATFS3_OSF1
# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512)

View File

@ -122,6 +122,7 @@ STATIC_INLINE int same_aname (const TCHAR *an1, const TCHAR *an2)
/* Filesystem-dependent functions. */
extern int fsdb_name_invalid (const TCHAR *n);
extern int fsdb_name_invalid_dir (const TCHAR *n);
extern int fsdb_fill_file_attrs (a_inode *, a_inode *);
extern int fsdb_set_file_attrs (a_inode *);
extern int fsdb_mode_representable_p (const a_inode *, int);

View File

@ -2794,9 +2794,9 @@ void memory_reset (void)
}
#endif
#endif
if (mem_hardreset)
if (mem_hardreset) {
memory_clear ();
}
write_log (_T("memory init end\n"));
}

View File

@ -832,6 +832,16 @@ void close_console (void)
return;
}
bool console_isch (void)
{
return false;
}
TCHAR console_getch (void)
{
return 0;
}
void debugger_change (int mode)
{
if (mode < 0)