This commit is contained in:
Toni Wilen 2016-02-14 18:43:20 +02:00
parent cb1e7a9bd5
commit fe95f7e14a
11 changed files with 1412 additions and 1262 deletions

View File

@ -119,7 +119,9 @@ static uae_u32 gettask (TrapContext *ctx)
trap_set_areg(ctx, 1, a1);
if (ISBSDTRACE) {
tskname = au((char*)get_real_address (trap_get_long(ctx, currtask + 10)));
uae_char name[256];
trap_get_string(ctx, name, trap_get_long(ctx, currtask + 10), sizeof name);
tskname = au(name);
BSDTRACE ((_T("[%s] "), tskname));
xfree (tskname);
}
@ -179,17 +181,17 @@ uae_u32 callfdcallback (TrapContext *ctx, SB, uae_u32 fd, uae_u32 action)
return v;
}
bool checksd(TrapContext *context, SB, int sd)
bool checksd(TrapContext *ctx, SB, int sd)
{
int iCounter;
SOCKET s;
s = getsock(sb,sd);
s = getsock(ctx, sb, sd);
if (s != INVALID_SOCKET) {
for (iCounter = 1; iCounter <= sb->dtablesize; iCounter++) {
if (iCounter != sd) {
if (getsock(sb,iCounter) == s) {
releasesock(context, sb, sd);
if (getsock(ctx, sb, iCounter) == s) {
releasesock(ctx, sb, sd);
return true;
}
}
@ -256,30 +258,35 @@ int getsd (TrapContext *ctx, SB, SOCKET_TYPE s)
return -1;
}
SOCKET_TYPE getsock (SB, int sd)
SOCKET_TYPE getsock (TrapContext *ctx, SB, int sd)
{
if ((unsigned int) (sd - 1) >= (unsigned int) sb->dtablesize) {
BSDTRACE ((_T("Invalid Socket Descriptor (%d)\n"), sd));
bsdsocklib_seterrno(NULL, sb, 38); /* ENOTSOCK */
bsdsocklib_seterrno(ctx, sb, 38); /* ENOTSOCK */
return -1;
}
if (sb->dtable[sd - 1] == INVALID_SOCKET) {
struct socketbase *sb1, *nsb;
uaecptr ot;
if (!addr_valid (_T("getsock1"), sb->ownertask + 10, 4))
uae_char name[256];
if (!trap_valid_address(ctx, sb->ownertask + 10, 4))
return -1;
ot = get_long (sb->ownertask + 10);
if (!addr_valid (_T("getsock2"), ot, 1))
ot = trap_get_long(ctx, sb->ownertask + 10);
if (!trap_valid_address(ctx, ot, 1))
return -1;
trap_get_string(ctx, name, ot, sizeof name);
// Fix for Newsrog (All Tasks of Newsrog using the same dtable)
for (sb1 = socketbases; sb1; sb1 = nsb) {
uaecptr ot1;
if (!addr_valid (_T("getsock3"), sb1->ownertask + 10, 4))
uae_char name1[256];
if (!trap_valid_address(ctx, sb1->ownertask + 10, 4))
break;
ot1 = get_long (sb1->ownertask + 10);
if (!addr_valid (_T("getsock4"), ot1, 1))
ot1 = trap_get_long(ctx, sb1->ownertask + 10);
if (!trap_valid_address(ctx, ot1, 1))
break;
if (strcmp((char*)get_real_address (ot1), (char*)get_real_address (ot)) == 0) {
trap_get_string(ctx, name1, ot1, sizeof name1);
if (strcmp(name, name1) == 0) {
// Task with same name already exists -> use same dtable
if (sb1->dtable[sd - 1] != INVALID_SOCKET)
return sb1->dtable[sd - 1];
@ -649,7 +656,7 @@ static uae_u32 REGPARAM2 bsdsocklib_setsockopt (TrapContext *ctx)
static uae_u32 REGPARAM2 bsdsocklib_getsockopt (TrapContext *ctx)
{
struct socketbase *sb = get_socketbase (ctx);
return host_getsockopt (sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2),
return host_getsockopt (ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2),
trap_get_areg(ctx, 0), trap_get_areg(ctx, 1));
}
@ -657,14 +664,14 @@ static uae_u32 REGPARAM2 bsdsocklib_getsockopt (TrapContext *ctx)
static uae_u32 REGPARAM2 bsdsocklib_getsockname (TrapContext *ctx)
{
struct socketbase *sb = get_socketbase (ctx);
return host_getsockname (sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1));
return host_getsockname (ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1));
}
/* getpeername(s, hostname, namelen)(d0/a0/a1) */
static uae_u32 REGPARAM2 bsdsocklib_getpeername (TrapContext *ctx)
{
struct socketbase *sb = get_socketbase (ctx);
return host_getpeername (sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1));
return host_getpeername (ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1));
}
/* *------ generic system calls related to sockets */
@ -810,7 +817,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *ctx)
sd++;
BSDTRACE ((_T("ReleaseSocket(%d,%d) -> "), sd, id));
s = getsock (sb, sd);
s = getsock (ctx, sb, sd);
if (s != -1) {
flags = sb->ftable[sd - 1];
@ -873,7 +880,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *ctx)
sd++;
BSDTRACE ((_T("ReleaseSocket(%d,%d) -> "), sd, id));
s = getsock (sb, sd);
s = getsock (ctx, sb, sd);
if (s != -1) {
flags = sb->ftable[sd - 1];
@ -931,7 +938,8 @@ static uae_u32 REGPARAM2 bsdsocklib_Errno (TrapContext *ctx)
static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr (TrapContext *ctx)
{
struct socketbase *sb = get_socketbase (ctx);
uae_u32 errnoptr = trap_get_areg(ctx, 0), size = trap_get_dreg(ctx, 0);
uae_u32 errnoptr = trap_get_areg(ctx, 0);
uae_u32 size = trap_get_dreg(ctx, 0);
BSDTRACE ((_T("SetErrnoPtr(0x%08x,%d) -> "), errnoptr, size));
@ -957,7 +965,7 @@ static uae_u32 REGPARAM2 bsdsocklib_Inet_NtoA (TrapContext *ctx)
/* inet_addr(cp)(a0) */
static uae_u32 REGPARAM2 bsdsocklib_inet_addr (TrapContext *ctx)
{
return host_inet_addr (trap_get_areg(ctx, 0));
return host_inet_addr(ctx, trap_get_areg(ctx, 0));
}
/* Inet_LnaOf(in)(d0) */
@ -984,7 +992,7 @@ static uae_u32 REGPARAM2 bsdsocklib_Inet_MakeAddr (TrapContext *ctx)
/* inet_network(cp)(a0) */
static uae_u32 REGPARAM2 bsdsocklib_inet_network (TrapContext *ctx)
{
return host_inet_addr (trap_get_areg(ctx, 0));
return host_inet_addr(ctx, trap_get_areg(ctx, 0));
}
/* *------ gethostbyname etc */
@ -1072,13 +1080,13 @@ static uae_u32 REGPARAM2 bsdsocklib_recvmsg (TrapContext *ctx)
static uae_u32 REGPARAM2 bsdsocklib_gethostname (TrapContext *ctx)
{
return host_gethostname (trap_get_areg(ctx, 0), trap_get_dreg(ctx, 0));
return host_gethostname(ctx, trap_get_areg(ctx, 0), trap_get_dreg(ctx, 0));
}
static uae_u32 REGPARAM2 bsdsocklib_gethostid (TrapContext *ctx)
{
write_log (_T("bsdsocket: WARNING: Process '%s' calls deprecated function gethostid() - returning 127.0.0.1\n"),
get_real_address (get_long (gettask(ctx) + 10)));
write_log (_T("bsdsocket: WARNING: Process %08x calls deprecated function gethostid() - returning 127.0.0.1\n"),
trap_get_long(ctx, gettask(ctx) + 10));
return 0x7f000001;
}

View File

@ -92,7 +92,7 @@ startjmp:
bra.w filesys_mainloop ;1 16
dc.l make_dev-start ;2 20
dc.l filesys_init-start ;3 24
dc.l exter_server-start ;4 28
dc.l 0 ;4 28
dc.l bootcode-start ;5 32
dc.l setup_exter-start ;6 36
dc.l bcplwrapper-start ;7 40
@ -385,7 +385,8 @@ FSIN_chip_done
EREM
createproc
movem.l d2-d4/a2/a6,-(sp)
movem.l d2-d5/a2/a6,-(sp)
moveq #0,d5
move.l 4.w,a6
move.l d0,d2
move.l d1,d4
@ -400,11 +401,13 @@ createproc
move.l a2,d1
lsr.l #2,d3
jsr -$08a(a6) ; CreateProc
move.l d0,d5
move.l a6,a1
move.l 4.w,a6
jsr -$019e(a6); CloseLibrary
.noproc
movem.l (sp)+,d2-d4/a2/a6
move.l d5,d0
movem.l (sp)+,d2-d5/a2/a6
rts
; this is getting ridiculous but I don't see any other solutions..
@ -499,7 +502,7 @@ EXTT_loop
jsr (a0)
tst.l d0
beq.w exter_task_wait
addq.w #1,d7
moveq #11,d7
cmp.w #1,d0
blt.w EXTT_loop
bgt.b EXTT_signal_reply
@ -523,7 +526,7 @@ EXTT_cause:
bra.b EXTT_loop
EXTT_notificationhack:
cmp.w #5,d0
bgt.b EXTT_loop
bgt.b EXTT_shellexec
movem.l a0-a1,-(sp)
moveq #38,d0
move.l #65536+1,d1
@ -540,8 +543,22 @@ EXTT_notificationhack:
move.l a2,a1
jsr -366(a6) ; PutMsg
bra.w EXTT_loop
EXTT_shellexec
cmp.w #6,d0
bgt.w EXTT_loop
lea shellexecname(pc),a0
lea shellexecproc(pc),a1
moveq #1,d0
move.l #10000,d1
bsr.w createproc
move.l d0,d1
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbase
moveq #20,d0
jsr (a0)
bra.w EXTT_loop
exter_server_new:
moveq #0,d0
move.l (a1)+,a0 ;IO Base
@ -556,72 +573,102 @@ exter_server_new:
tst.w d0
rts
exter_server:
movem.l a2,-(sp)
tst.b (a1)
beq.w exter_server_exit
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbase
moveq #0,d0
jsr (a0)
tst.l d0
beq.w exter_server_exit
; This is the hard part - we have to send some messages.
cnop 0,4
dc.l 16
shellexecproc:
dc.l 0
move.l 4.w,a6
EXTS_loop:
lea doslibname(pc),a1
moveq #0,d0
jsr -$228(a6) ; OpenLibrary
move.l d0,a5
exg a5,a6
bra.s .seproc1
.seproc0
exg a5,a6
moveq #0,d0
bset #13,d0 ; SIGBREAK_CTRL_D
jsr -$013e(a6) ;Wait
exg a5,a6
.seproc1
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbase
moveq.l #2,d0
moveq #21,d0
jsr (a0)
cmp.w #1,d0
blt.w EXTS_done
bgt.b EXTS_signal_reply
jsr -366(a6) ; PutMsg
bra.b EXTS_loop
EXTS_signal_reply:
cmp.w #2,d0
bgt.b EXTS_reply
move.l d1,d0
jsr -$144(a6) ; Signal
bra.b EXTS_loop
EXTS_reply:
cmp.w #3,d0
bgt.b EXTS_cause
jsr -$17a(a6) ; ReplyMsg
bra.b EXTS_loop
EXTS_cause:
cmp.w #4,d0
bgt.b EXTS_notificationhack
jsr -$b4(a6) ; Cause
bra.b EXTS_loop
EXTS_notificationhack:
cmp.w #5,d0
bgt.b EXTS_done
movem.l a0-a1,-(sp)
moveq #38,d0
move.l #65536+1,d1
jsr AllocMem(a6)
movem.l (sp)+,a0-a1
move.l d0,a2
move.b #8,8(a2)
move.l a0,14(a2)
move.w #38,18(a2)
move.l #NOTIFY_CLASS,20(a2)
move.w #NOTIFY_CODE,24(a2)
move.l a1,26(a2)
move.l 16(a1),a0
move.l a2,a1
jsr -366(a6) ; PutMsg
bra.w EXTS_loop
EXTS_done:
move.w #$FF50,d0 ;exter_int_helper
; a0 = command
move.l a0,d7
beq.s .seproc0
move.l sp,a4
lea -5*8-512(sp),sp
move.l sp,d6
move.l d6,a2
lea 5*8(a2),a3
move.l a3,a1
move.l d7,a0
.seproc2
move.b (a0)+,(a1)+
bne.s .seproc2
move.l d7,a0
clr.b (a0)
; SYS_Input
move.l #$80000000+32+1,(a2)+
lea nil_name(pc),a0
move.l a0,d1
move.l #1005,d2
jsr -$1e(a6) ;Open
move.l d0,(a2)+
; SYS_Output
move.l #$80000000+32+2,(a2)+
lea nil_name(pc),a0
move.l a0,d1
jsr -$1e(a6) ;Open
move.l d0,(a2)+
; SYS_Async
move.l #$80000000+32+3,(a2)+
moveq #-1,d0
move.l d0,(a2)+
clr.l (a2)+
clr.l (a2)
cmp.w #36,20(a6)
bcc.s .seproc3
move.l d6,a2
move.l a3,d1 ;Command
moveq #0,d2 ;Input
move.l 1*8+4(a2),d3 ;Output
jsr -$de(a6) ;Execute
move.l 0*8+4(a2),d1
jsr -$24(a6) ;Close
move.l 1*8+4(a2),d1
jsr -$24(a6) ;Close
bra.s .seproc4
.seproc3
move.l a3,d1
move.l d6,d2
jsr -$25e(a6) ; SystemTagList
.seproc4
move.l a4,sp
move.w #$FF50,d0 ; exter_int_helper
bsr.w getrtbase
moveq.l #4,d0
jsr (a0)
moveq.l #1,d0 ; clear Z - it was for us.
exter_server_exit:
movem.l (sp)+,a2
rts
moveq #22,d0
jsr (a0)
bra.w .seproc0
; d0 = exter task, d1 = trap task
heartbeatvblank:
@ -1149,7 +1196,23 @@ action_inhibit
bsr dodiskchange
rts
sethighcyl
move.l 184(a3),d0 ;highcyl or -1
cmp.l #-1,d0
beq.s .nohighcyl
move.l 180(a3),a0 ;devicenode
move.l 7*4(a0),a0 ;startup
add.l a0,a0
add.l a0,a0
move.l 8(a0),a0 ; dosenvec
add.l a0,a0
add.l a0,a0
move.l d0,10*4(a0)
.nohighcyl
rts
diskchange
bsr.w sethighcyl
move.b 172(a3),d0
bmi.s .nodisk
moveq #1,d0
@ -1535,16 +1598,30 @@ filesys_mainloop_bcpl:
; 173: bit 0: clock reset, bit 1: debugger start
; 176: my task
; 180: device node
move.l #12+20+(80+44+1)+(1+3)+4+4+4+(1+3)+4+4,d0
; 184: highcyl (-1 = ignore)
move.l #12+20+(80+44+1)+3+4+4+4+(1+3)+4+4+4,d1
move.w #$FF40,d0 ; startup_handler
bsr.w getrtbase
moveq #1,d0
jsr (a0)
; if d0 != 0, it becomes our memory space
; "allocated" from our autoconfig RAM space
tst.l d0
bne.s .havemem
move.l d1,d0
move.l #$10001,d1 ; MEMF_PUBLIC | MEMF_CLEAR
jsr AllocMem(a6)
.havemem
move.l d0,a3
moveq.l #0,d6
moveq #0,d6
move.l d6,(a3)
move.l d6,4(a3)
move.l d6,8(a3)
move.l a2,160(a3)
st 158(a3)
moveq #-1,d0
move.l d0,184(a3)
sub.l a1,a1
jsr -294(a6) ; FindTask
@ -1573,12 +1650,15 @@ filesys_mainloop_bcpl:
move.l d0,a4
move.l 10(a4),d3 ; ln_Name -> startup dos packet
.got_bcpl
move.w #$FF40,d0 ; startup_handler
bsr.w getrtbase
moveq.l #0,d0
moveq #0,d0
jsr (a0)
move.l d0,d2
bsr.w sethighcyl
moveq #1,d0
bsr.w addvolumenode
@ -3362,20 +3442,17 @@ hw_get_byte:
hw_copy_bytes:
; a0 = src, a1 = dest, d2 = bytes
move.l d2,d0
jsr -$270(a6) ; CopyMem
rts
jmp -$270(a6) ; CopyMem
hw_copy_words:
; a0 = src, a1 = dest, d2 = words
move.l d2,d0
add.l d0,d0
jsr -$270(a6) ; CopyMem
rts
jmp -$270(a6) ; CopyMem
hw_copy_longs:
; a0 = src, a1 = dest, d2 = longs
move.l d2,d0
lsl.l #2,d0
jsr -$270(a6) ; CopyMem
rts
jmp -$270(a6) ; CopyMem
hw_copy_string:
; a0 = src, a1 = dest, d2 = maxlen
moveq #0,d0
@ -3501,6 +3578,7 @@ devsn_name: dc.b 'DEVS',0
devs_name: dc.b 'DEVS:',0
clip_name: dc.b 'DEVS:clipboard.device',0
ram_name: dc.b 'RAM:',0
nil_name: dc.b "NIL:",0
clip_dev: dc.b 'clipboard.device',0
;argghh but StartNotify()ing non-existing ENV: causes "Insert disk ENV: in any drive" dialog..
pointer_prefs: dc.b 'RAM:Env/Sys/Pointer.prefs',0
@ -3520,6 +3598,7 @@ explibname: dc.b 'expansion.library',0
fsresname: dc.b 'FileSystem.resource',0
fchipname: dc.b 'megachip memory',0
bcplfsname: dc.b "File System",0
shellexecname: dc.b "UAE shell execute",0
even
rom_end:

File diff suppressed because it is too large Load Diff

10
fpp.cpp
View File

@ -134,7 +134,7 @@ static floatx80 fxzero;
static floatx80 fx_1e0, fx_1e1, fx_1e2, fx_1e4, fx_1e8;
struct float_status_t fxstatus;
#endif
static fptype fsizes[] = { -128.0, 127.0, -32768.0, 32767.0, -2147483648.0, 2147483647.0 };
static const fptype fsizes[] = { -128.0, 127.0, -32768.0, 32767.0, -2147483648.0, 2147483647.0 };
#define FP_INEXACT (1 << 9)
#define FP_DIVBYZERO (1 << 10)
@ -587,12 +587,14 @@ static inline void set_fpucw_x87(uae_u32 m68k_cw)
static const unsigned int fp87_round[4] = { _RC_NEAR, _RC_CHOP, _RC_DOWN, _RC_UP };
// Extend X, Single S, Double D, Undefined
static const unsigned int fp87_prec[4] = { _PC_64, _PC_24, _PC_53, 0 };
int round = (m68k_cw >> 4) & 3;
#ifdef WIN64
// x64 only sets SSE2, must also call x87_fldcw_code() to set FPU rounding mode.
_controlfp(ex | fp87_round[(m68k_cw >> 4) & 3], _MCW_RC);
_controlfp(ex | fp87_round[round], _MCW_RC);
#else
int prec = (m68k_cw >> 6) & 3;
// x86 sets both FPU and SSE2 rounding mode, don't need x87_fldcw_code()
_control87(ex | fp87_round[(m68k_cw >> 4) & 3] | fp87_prec[(m68k_cw >> 6) & 3], _MCW_RC | _MCW_PC);
_control87(ex | fp87_round[round] | fp87_prec[prec], _MCW_RC | _MCW_PC);
return;
#endif
#endif
@ -619,8 +621,6 @@ static void native_set_fpucw(uae_u32 m68k_cw)
#ifdef WITH_SOFTFLOAT
if (currprefs.fpu_softfloat) {
set_fpucw_softfloat(m68k_cw);
/* FIXME: consider removing return to *also* set x87 fpucw? */
return;
}
#endif
#if defined(CPU_i386) || defined(CPU_x86_64)

View File

@ -154,7 +154,7 @@ extern void unlocksigqueue (void);
extern bool checksd(TrapContext*, SB, int sd);
extern void setsd(TrapContext*, SB, int , SOCKET_TYPE);
extern int getsd (TrapContext*, SB, SOCKET_TYPE);
extern SOCKET_TYPE getsock (SB, int);
extern SOCKET_TYPE getsock (TrapContext*, SB, int);
extern void releasesock (TrapContext*, SB, int);
extern void waitsig (TrapContext *context, SB);
@ -174,9 +174,9 @@ extern void host_sendto (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32,
extern void host_recvfrom (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown (SB, uae_u32, uae_u32);
extern void host_setsockopt (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockopt (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockname (SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getpeername (SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockopt (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockname (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getpeername (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_IoctlSocket (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown (SB, uae_u32, uae_u32);
extern int host_CloseSocket (TrapContext *, SB, int);
@ -187,8 +187,8 @@ extern uae_u32 host_getdtablesize (void);
extern uae_u32 host_ObtainSocket (void);
extern uae_u32 host_ReleaseSocket (void);
extern uae_u32 host_ReleaseCopyOfSocket (void);
extern uae_u32 host_Inet_NtoA (TrapContext *context, SB, uae_u32);
extern uae_u32 host_inet_addr (uae_u32);
extern uae_u32 host_Inet_NtoA(TrapContext *ctx, SB, uae_u32);
extern uae_u32 host_inet_addr(TrapContext *ctx, uae_u32);
extern uae_u32 host_Inet_LnaOf (void);
extern uae_u32 host_Inet_NetOf (void);
extern uae_u32 host_Inet_MakeAddr (void);
@ -201,8 +201,8 @@ extern void host_getprotobyname (TrapContext *, SB, uae_u32);
extern void host_getprotobynumber (TrapContext *, SB, uae_u32);
extern uae_u32 host_vsyslog (void);
extern uae_u32 host_Dup2Socket (void);
extern uae_u32 host_gethostname (uae_u32, uae_u32);
extern uae_u32 callfdcallback (TrapContext *context, SB, uae_u32 fd, uae_u32 action);
extern uae_u32 host_gethostname(TrapContext *ctx, uae_u32, uae_u32);
extern uae_u32 callfdcallback(TrapContext *context, SB, uae_u32 fd, uae_u32 action);
extern uaecptr bsdlib_startup (TrapContext*, uaecptr);
extern void bsdlib_install (void);

View File

@ -105,6 +105,7 @@ void trap_memcpyha_safe(TrapContext *ctx, uaecptr dst, const uae_u8 *src, int si
void trap_memcpyah_safe(TrapContext *ctx, uae_u8 *dst, uaecptr src, int size);
TrapContext *alloc_host_main_trap_context(void);
TrapContext *alloc_host_thread_trap_context(void);
void free_host_trap_context(TrapContext*);
uae_u32 trap_get_dreg(TrapContext *ctx, int reg);
@ -129,6 +130,7 @@ void trap_get_words(TrapContext *ctx, uae_u16 *haddr, uaecptr addr, int cnt);
int trap_put_string(TrapContext *ctx, const void *haddrp, uaecptr addr, int maxlen);
int trap_get_string(TrapContext *ctx, void *haddrp, uaecptr addr, int maxlen);
uae_char *trap_get_alloc_string(TrapContext *ctx, uaecptr addr, int maxlen);
void trap_set_longs(TrapContext *ctx, uaecptr addr, uae_u32 v, int cnt);
void trap_set_words(TrapContext *ctx, uaecptr addr, uae_u16 v, int cnt);

View File

@ -397,6 +397,7 @@ static void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam)
SB;
unsigned int index;
int sdi;
TrapContext *ctx = NULL;
index = (msg - 0xb000) / 2;
sb = bsd->asyncsb[index];
@ -448,13 +449,18 @@ static void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam)
if (WSAGETASYNCERROR(lParam)) {
bsdsocklib_seterrno(NULL, sb, WSAGETASYNCERROR(lParam) - WSABASEERR);
if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) {
bsdsocklib_setherrno(NULL, sb, sb->sb_errno - 1000);
TrapContext *ctx = alloc_host_thread_trap_context();
bsdsocklib_setherrno(ctx, sb, sb->sb_errno - 1000);
free_host_trap_context(ctx);
} else if (sb->sb_errno == 55) { // ENOBUFS
write_log (_T("BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n"),
WSAGETASYNCBUFLEN(lParam));
}
} else {
bsdsocklib_seterrno(NULL, sb,0);
TrapContext *ctx = alloc_host_thread_trap_context();
bsdsocklib_seterrno(ctx, sb,0);
free_host_trap_context(ctx);
}
SETSIGNAL;
@ -463,7 +469,7 @@ static void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam)
unlocksigqueue();
}
static unsigned int allocasyncmsg(SB,uae_u32 sd,SOCKET s)
static unsigned int allocasyncmsg(TrapContext *ctx, SB,uae_u32 sd,SOCKET s)
{
int i;
@ -487,7 +493,7 @@ static unsigned int allocasyncmsg(SB,uae_u32 sd,SOCKET s)
}
unlocksigqueue();
bsdsocklib_seterrno(NULL, sb, 12); // ENOMEM
bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM
write_log (_T("BSDSOCK: ERROR - Async operation completion table overflow\n"));
return 0;
@ -571,7 +577,7 @@ int host_dup2socket(TrapContext *ctx, SB, int fd1, int fd2)
BSDTRACE((_T("dup2socket(%d,%d) -> "),fd1,fd2));
fd1++;
s1 = getsock(sb, fd1);
s1 = getsock(ctx, sb, fd1);
if (s1 != INVALID_SOCKET) {
if (fd2 != -1) {
if ((unsigned int) (fd2) >= (unsigned int) sb->dtablesize) {
@ -579,7 +585,7 @@ int host_dup2socket(TrapContext *ctx, SB, int fd1, int fd2)
bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */
}
fd2++;
s2 = getsock(sb,fd2);
s2 = getsock(ctx, sb, fd2);
if (s2 != INVALID_SOCKET) {
shutdown(s2,1);
closesocket(s2);
@ -649,7 +655,7 @@ uae_u32 host_bind(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namele
sd++;
BSDTRACE((_T("bind(%d,0x%x,%d) -> "),sd, name, namelen));
s = getsock(sb, sd);
s = getsock(ctx, sb, sd);
if (s != INVALID_SOCKET) {
if (namelen <= sizeof buf) {
@ -679,7 +685,7 @@ uae_u32 host_listen(TrapContext *ctx, SB, uae_u32 sd, uae_u32 backlog)
sd++;
BSDTRACE((_T("listen(%d,%d) -> "), sd, backlog));
s = getsock(sb, sd);
s = getsock(ctx, sb, sd);
if (s != INVALID_SOCKET) {
if ((success = listen(s,backlog)) != 0) {
@ -702,10 +708,10 @@ void host_accept(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen
sd++;
if (name != 0) {
if (!addr_valid (_T("host_accept1"), name, sizeof(struct sockaddr)) || !addr_valid (_T("host_accept2"), namelen, 4))
if (!trap_valid_address(ctx, name, sizeof(struct sockaddr)) || !trap_valid_address(ctx, namelen, 4))
return;
rp_nameuae = rp_name = (struct sockaddr *)get_real_address (name);
hlenuae = hlen = get_long (namelen);
hlenuae = hlen = trap_get_long(ctx, namelen);
if (hlenuae < sizeof(sockaddr))
{ // Fix for CNET BBS Windows must have 16 Bytes (sizeof(sockaddr)) otherwise Error WSAEFAULT
rp_name = &sockaddr;
@ -717,7 +723,7 @@ void host_accept(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen
}
BSDTRACE((_T("accept(%d,%d,%d) -> "),sd,name,hlenuae));
s = getsock(sb, (int)sd);
s = getsock(ctx, sb, (int)sd);
if (s != INVALID_SOCKET) {
BEGINBLOCKING;
@ -728,7 +734,7 @@ void host_accept(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen
SETERRNO;
if ((sb->ftable[sd - 1] & SF_BLOCKING) && sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR) {
if (sb->mtable[sd - 1] || (wMsg = allocasyncmsg(sb, sd, s)) != 0) {
if (sb->mtable[sd - 1] || (wMsg = allocasyncmsg(ctx, sb, sd, s)) != 0) {
if (sb->mtable[sd - 1] == 0) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : bsd->hSockWnd, wMsg, FD_ACCEPT);
} else {
@ -773,13 +779,13 @@ void host_accept(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen
if (hlen <= hlenuae) { // Fix for CNET BBS Part 2
prepamigaaddr(rp_name, hlen);
if (namelen != 0) {
put_long (namelen, hlen);
trap_put_long(ctx, namelen, hlen);
}
} else { // Copy only the number of bytes requested
if (hlenuae != 0) {
prepamigaaddr(rp_name, hlenuae);
memcpy(rp_nameuae, rp_name, hlenuae);
put_long (namelen, hlenuae);
trap_put_long(ctx, namelen, hlenuae);
}
}
}
@ -978,11 +984,11 @@ void host_connect(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namele
if (!addr_valid (_T("host_connect"), name, namelen))
return;
s = getsock(sb,(int)sd);
s = getsock(ctx, sb,(int)sd);
if (s != INVALID_SOCKET) {
if (namelen <= MAXADDRLEN) {
if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) {
if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(ctx, sb,sd,s)) != 0) {
if (sb->mtable[sd-1] == 0) {
WSAAsyncSelect(s, hWndSelector ? hAmigaWnd : bsd->hSockWnd, wMsg, FD_CONNECT);
} else {
@ -1083,7 +1089,7 @@ void host_sendto (TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, ua
BSDTRACE((_T("send(%d,0x%x,%d,%d):%d -> "),sd,msg,len,flags,wscnt));
sd++;
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (!addr_valid (_T("host_sendto1"), msg, 4))
@ -1189,7 +1195,7 @@ void host_sendto (TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, ua
continue;
}
if (sb->mtable[sd - 1] || (wMsg = allocasyncmsg(sb, sd, s)) != 0) {
if (sb->mtable[sd - 1] || (wMsg = allocasyncmsg(ctx, sb, sd, s)) != 0) {
if (sb->mtable[sd - 1] == 0) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : bsd->hSockWnd,wMsg,FD_WRITE);
} else {
@ -1242,7 +1248,7 @@ void host_recvfrom(TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, u
BSDTRACE((_T("recv(%d,0x%x,%d,0x%x):%d -> "),sd,msg,len,flags,wscnt));
sd++;
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (!addr_valid (_T("host_recvfrom1"), msg, 4))
@ -1302,7 +1308,7 @@ void host_recvfrom(TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, u
if (sb->resultval == -1) {
if (sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR && (sb->ftable[sd-1] & SF_BLOCKING)) {
if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) {
if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(ctx, sb,sd,s)) != 0) {
if (sb->mtable[sd-1] == 0) {
WSAAsyncSelect(s, hWndSelector ? hAmigaWnd : bsd->hSockWnd, wMsg, FD_READ|FD_CLOSE);
} else {
@ -1352,7 +1358,7 @@ uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how)
BSDTRACE((_T("shutdown(%d,%d) -> "),sd,how));
sd++;
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (shutdown(s,how)) {
@ -1376,7 +1382,7 @@ void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 opt
BSDTRACE((_T("setsockopt(%d,%d,0x%x,0x%x[0x%x],%d) -> "),sd,(short)level,optname,optval,get_long(optval),len));
sd++;
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (len > sizeof buf) {
@ -1424,7 +1430,7 @@ void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 opt
if (eventflags & REP_CLOSE)
wsbevents |= FD_CLOSE;
if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s))) {
if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(ctx, sb,sd,s))) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : bsd->hSockWnd,sb->mtable[sd-1],wsbevents);
sb->resultval = 0;
} else
@ -1443,9 +1449,8 @@ void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 opt
}
}
uae_u32 host_getsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen)
uae_u32 host_getsockopt(TrapContext *ctx, SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen)
{
TrapContext *ctx = NULL;
SOCKET s;
uae_char buf[MAXADDRLEN];
int len = sizeof buf;
@ -1458,7 +1463,7 @@ uae_u32 host_getsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32
BSDTRACE((_T("getsockopt(%d,%d,0x%x,0x%x,0x%x[%d]) -> "),sd,(short)level,optname,optval,optlen,outlen));
sd++;
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (!getsockopt(s,level,optname,buf,&len)) {
@ -1508,12 +1513,11 @@ uae_u32 host_getsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32
return -1;
}
uae_u32 host_getsockname(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
uae_u32 host_getsockname(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
{
SOCKET s;
int len;
struct sockaddr *rp_name;
TrapContext *ctx = NULL;
sd++;
if (!addr_valid (_T("host_getsockname1"), namelen, 4))
@ -1522,10 +1526,10 @@ uae_u32 host_getsockname(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
BSDTRACE((_T("getsockname(%d,0x%x,%d) -> "),sd,name,len));
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (!addr_valid (_T("host_getsockname2"), name, len))
if (!trap_valid_address(ctx, name, len))
return -1;
rp_name = (struct sockaddr *)get_real_address (name);
@ -1543,12 +1547,11 @@ uae_u32 host_getsockname(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
return -1;
}
uae_u32 host_getpeername(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
uae_u32 host_getpeername(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
{
SOCKET s;
int len;
struct sockaddr *rp_name;
TrapContext *ctx = NULL;
sd++;
if (!addr_valid (_T("host_getpeername1"), namelen, 4))
@ -1557,10 +1560,10 @@ uae_u32 host_getpeername(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
BSDTRACE((_T("getpeername(%d,0x%x,%d) -> "),sd,name,len));
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (!addr_valid (_T("host_getpeername2"), name, len))
if (!trap_valid_address(ctx, name, len))
return -1;
rp_name = (struct sockaddr *)get_real_address (name);
@ -1586,22 +1589,22 @@ uae_u32 host_IoctlSocket(TrapContext *ctx, SB, uae_u32 sd, uae_u32 request, uae_
BSDTRACE((_T("IoctlSocket(%d,0x%x,0x%x) "),sd,request,arg));
sd++;
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
switch (request)
{
case FIOSETOWN:
sb->ownertask = get_long (arg);
sb->ownertask = trap_get_long(ctx, arg);
success = 0;
break;
case FIOGETOWN:
put_long (arg,sb->ownertask);
trap_put_long(ctx, arg,sb->ownertask);
success = 0;
break;
case FIONBIO:
BSDTRACE((_T("[FIONBIO] -> ")));
if (get_long (arg)) {
if (trap_get_long(ctx, arg)) {
BSDTRACE((_T("nonblocking\n")));
sb->ftable[sd-1] &= ~SF_BLOCKING;
} else {
@ -1613,15 +1616,15 @@ uae_u32 host_IoctlSocket(TrapContext *ctx, SB, uae_u32 sd, uae_u32 request, uae_
case FIONREAD:
ioctlsocket(s,request,(u_long *)&data);
BSDTRACE((_T("[FIONREAD] -> %d\n"),data));
put_long (arg,data);
trap_put_long(ctx, arg,data);
success = 0;
break;
case FIOASYNC:
if (get_long (arg)) {
if (trap_get_long(ctx, arg)) {
sb->ftable[sd-1] |= REP_ALL;
BSDTRACE((_T("[FIOASYNC] -> enabled\n")));
if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s))) {
if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(ctx, sb, sd, s))) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : bsd-> hSockWnd, sb->mtable[sd-1],
FD_ACCEPT | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE | FD_CLOSE);
success = 0;
@ -1651,7 +1654,7 @@ int host_CloseSocket(TrapContext *ctx, SB, int sd)
BSDTRACE((_T("CloseSocket(%d) -> "),sd));
sd++;
s = getsock(sb,sd);
s = getsock(ctx, sb,sd);
if (s != INVALID_SOCKET) {
if (sb->mtable[sd-1]) {
@ -1678,7 +1681,7 @@ int host_CloseSocket(TrapContext *ctx, SB, int sd)
if (sb->sb_errno != WSAEWOULDBLOCK-WSABASEERR || !(sb->ftable[sd-1] & SF_BLOCKING))
break;
if ((wMsg = allocasyncmsg(sb,sd,s)) != 0) {
if ((wMsg = allocasyncmsg(ctx, sb, sd, s)) != 0) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : bsd->hSockWnd,wMsg,FD_CLOSE);
WAITSIGNAL;
@ -1703,7 +1706,7 @@ int host_CloseSocket(TrapContext *ctx, SB, int sd)
// For the sake of efficiency, we do not malloc() the fd_sets here.
// 64 sockets should be enough for everyone.
static void makesocktable(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, int nfds, SOCKET addthis, const TCHAR *name)
static void makesocktable(TrapContext *ctx, SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, int nfds, SOCKET addthis, const TCHAR *name)
{
int i, j;
uae_u32 currlong, mask;
@ -1726,7 +1729,7 @@ static void makesocktable(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, i
}
for (j = 0; ; j += 32, fd_set_amiga += 4) {
currlong = get_long (fd_set_amiga);
currlong = trap_get_long (ctx, fd_set_amiga);
mask = 1;
@ -1737,7 +1740,7 @@ static void makesocktable(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, i
}
if (currlong & mask) {
s = getsock(sb,j+i+1);
s = getsock(ctx, sb,j+i+1);
if (s != INVALID_SOCKET) {
BSDTRACE((_T("%s:%d=%x\n"), name, fd_set_win->fd_count, s));
@ -1755,7 +1758,7 @@ static void makesocktable(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, i
fd_set_win->fd_array[fd_set_win->fd_count] = INVALID_SOCKET;
}
static void makesockbitfield(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, int nfds)
static void makesockbitfield(TrapContext *ctx, SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, int nfds)
{
int n, i, j, val, mask;
SOCKET currsock;
@ -1765,7 +1768,7 @@ static void makesockbitfield(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win
mask = 1;
for (i = 0; i < 32; i++, mask <<= 1) {
if ((currsock = getsock(sb, n+i+1)) != INVALID_SOCKET) {
if ((currsock = getsock(ctx, sb, n+i+1)) != INVALID_SOCKET) {
// Do not use sb->dtable directly because of Newsrog
for (j = fd_set_win->fd_count; j--; ) {
if (fd_set_win->fd_array[j] == currsock) {
@ -1775,16 +1778,16 @@ static void makesockbitfield(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win
}
}
}
put_long (fd_set_amiga, val);
trap_put_long(ctx, fd_set_amiga, val);
fd_set_amiga += 4;
}
}
static void fd_zero(uae_u32 fdset, uae_u32 nfds)
static void fd_zero(TrapContext *ctx, uae_u32 fdset, uae_u32 nfds)
{
unsigned int i;
for (i = 0; i < nfds; i += 32, fdset += 4)
put_long (fdset,0);
trap_put_long(ctx, fdset,0);
}
// This seems to be the only way of implementing a cancelable WinSock2 select() call... sigh.
@ -1819,11 +1822,11 @@ static unsigned int thread_WaitSelect2(void *indexp)
wscnt = args->wscnt;
// construct descriptor tables
makesocktable(sb, readfds, &readsocks, nfds, sb->sockAbort, _T("R"));
makesocktable(ctx, sb, readfds, &readsocks, nfds, sb->sockAbort, _T("R"));
if (writefds)
makesocktable(sb, writefds, &writesocks, nfds, INVALID_SOCKET, _T("W"));
makesocktable(ctx, sb, writefds, &writesocks, nfds, INVALID_SOCKET, _T("W"));
if (exceptfds)
makesocktable(sb, exceptfds, &exceptsocks, nfds, INVALID_SOCKET, _T("E"));
makesocktable(ctx, sb, exceptfds, &exceptsocks, nfds, INVALID_SOCKET, _T("E"));
if (timeout) {
tv.tv_sec = get_long (timeout);
@ -1850,7 +1853,7 @@ static unsigned int thread_WaitSelect2(void *indexp)
if (sb->resultval == SOCKET_ERROR) {
// select was stopped by sb->sockAbort
if (readsocks.fd_count > 1) {
makesocktable(sb, readfds, &readsocks, nfds, INVALID_SOCKET, _T("R2"));
makesocktable(ctx, sb, readfds, &readsocks, nfds, INVALID_SOCKET, _T("R2"));
tv.tv_sec = 0;
tv.tv_usec = 10000;
// Check for 10ms if data is available
@ -1882,19 +1885,19 @@ static unsigned int thread_WaitSelect2(void *indexp)
SETERRNO;
BSDTRACE((_T("tWS2 failed %d:%d - "),sb->sb_errno,wscnt));
if (readfds)
fd_zero(readfds,nfds);
fd_zero(ctx, readfds,nfds);
if (writefds)
fd_zero(writefds,nfds);
fd_zero(ctx, writefds,nfds);
if (exceptfds)
fd_zero(exceptfds,nfds);
fd_zero(ctx, exceptfds,nfds);
} else {
BSDTRACE((_T("tWS2 ok %d\n"), wscnt));
if (readfds)
makesockbitfield(sb,readfds,&readsocks,nfds);
makesockbitfield(ctx, sb,readfds,&readsocks,nfds);
if (writefds)
makesockbitfield(sb,writefds,&writesocks,nfds);
makesockbitfield(ctx, sb,writefds,&writesocks,nfds);
if (exceptfds)
makesockbitfield(sb,exceptfds,&exceptsocks,nfds);
makesockbitfield(ctx, sb,exceptfds,&exceptsocks,nfds);
}
SETSIGNAL;
@ -1944,7 +1947,7 @@ void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u3
wscnt = ++wscount;
wssigs = sigmp ? get_long (sigmp) : 0;
wssigs = sigmp ? trap_get_long(ctx, sigmp) : 0;
BSDTRACE((_T("WaitSelect(%d,0x%x,0x%x,0x%x,0x%x,0x%x):%d\n"),
nfds, readfds, writefds, exceptfds, timeout, wssigs, wscnt));
@ -1958,20 +1961,20 @@ void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u3
return;
}
if (wssigs) {
m68k_dreg (regs,0) = 0;
m68k_dreg (regs,1) = wssigs;
sigs = CallLib(ctx, sb->sysbase, -0x132) & wssigs; // SetSignal()
trap_call_add_dreg(ctx ,0, 0);
trap_call_add_dreg(ctx, 1, wssigs);
sigs = trap_call_lib(ctx, sb->sysbase, -0x132) & wssigs; // SetSignal()
if (sigs) {
BSDTRACE((_T("-> [preempted by signals 0x%08lx]\n"),sigs & wssigs));
put_long (sigmp,sigs & wssigs);
// Check for zero address -> otherwise WinUAE crashes
if (readfds)
fd_zero(readfds,nfds);
fd_zero(ctx, readfds,nfds);
if (writefds)
fd_zero(writefds,nfds);
fd_zero(ctx, writefds,nfds);
if (exceptfds)
fd_zero(exceptfds,nfds);
fd_zero(ctx, exceptfds,nfds);
sb->resultval = 0;
bsdsocklib_seterrno(ctx, sb,0);
return;
@ -1980,17 +1983,17 @@ void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u3
if (nfds == 0) {
// No sockets to check, only wait for signals
if (wssigs != 0) {
m68k_dreg (regs, 0) = wssigs;
sigs = CallLib(ctx, sb->sysbase, -0x13e); // Wait()
put_long (sigmp, sigs & wssigs);
trap_call_add_dreg(ctx, 0, wssigs);
sigs = trap_call_lib(ctx, sb->sysbase, -0x13e); // Wait()
trap_put_long(ctx, sigmp, sigs & wssigs);
}
if (readfds)
fd_zero(readfds,nfds);
fd_zero(ctx, readfds,nfds);
if (writefds)
fd_zero(writefds,nfds);
fd_zero(ctx, writefds,nfds);
if (exceptfds)
fd_zero(exceptfds,nfds);
fd_zero(ctx, exceptfds,nfds);
sb->resultval = 0;
return;
}
@ -2046,8 +2049,8 @@ void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u3
SetEvent(bsd->hEvents[i]);
m68k_dreg (regs, 0) = (((uae_u32)1) << sb->signal) | sb->eintrsigs | wssigs;
sigs = CallLib(ctx, sb->sysbase, -0x13e); // Wait()
trap_call_add_dreg(ctx, 0, (((uae_u32)1) << sb->signal) | sb->eintrsigs | wssigs);
sigs = trap_call_lib(ctx, sb->sysbase, -0x13e); // Wait()
/*
if ((1<<sb->signal) & sigs)
{ // 2.3.2002/SR Fix for AmiFTP -> Thread is ready, no need to Abort
@ -2072,14 +2075,14 @@ void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u3
sb->sockAbort = newsock;
if(sigmp)
put_long (sigmp, sigs & wssigs);
trap_put_long(ctx, sigmp, sigs & wssigs);
if (sigs & wssigs) {
uae_u32 gotsigs = sigs & wssigs;
BSDTRACE((_T("[interrupted by signals 0x%08lx]:%d\n"), gotsigs, wscnt));
if (readfds) fd_zero(readfds,nfds);
if (writefds) fd_zero(writefds,nfds);
if (exceptfds) fd_zero(exceptfds,nfds);
if (readfds) fd_zero(ctx, readfds,nfds);
if (writefds) fd_zero(ctx, writefds,nfds);
if (exceptfds) fd_zero(ctx, exceptfds,nfds);
bsdsocklib_seterrno(ctx, sb, 0);
sb->resultval = 0;
} else if (sigs & sb->eintrsigs) {
@ -2088,9 +2091,9 @@ void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u3
sb->resultval = -1;
bsdsocklib_seterrno(ctx, sb, 4); // EINTR
/* EINTR signals are kept active */
m68k_dreg (regs,0) = gotsigs;
m68k_dreg (regs,1) = gotsigs;
CallLib (ctx, sb->sysbase, -0x132); // SetSignal
trap_call_add_dreg(ctx, 0, gotsigs);
trap_call_add_dreg(ctx, 1, gotsigs);
trap_call_lib(ctx, sb->sysbase, -0x132); // SetSignal
}
if (sb->resultval >= 0) {
@ -2112,8 +2115,8 @@ uae_u32 host_Inet_NtoA(TrapContext *ctx, SB, uae_u32 in)
BSDTRACE((_T("Inet_NtoA(%x) -> "),in));
if ((addr = inet_ntoa(ina)) != NULL) {
scratchbuf = m68k_areg (regs,6) + offsetof(struct UAEBSDBase,scratchbuf);
strncpyha(ctx, scratchbuf,addr,SCRATCHBUFSIZE);
scratchbuf = trap_get_areg(ctx, 6) + offsetof(struct UAEBSDBase,scratchbuf);
strncpyha(ctx, scratchbuf, addr, SCRATCHBUFSIZE);
if (ISBSDTRACE) {
TCHAR *s = au (addr);
BSDTRACE((_T("%s\n"),s));
@ -2128,22 +2131,21 @@ uae_u32 host_Inet_NtoA(TrapContext *ctx, SB, uae_u32 in)
return 0;
}
uae_u32 host_inet_addr(uae_u32 cp)
uae_u32 host_inet_addr(TrapContext *ctx, uae_u32 cp)
{
uae_u32 addr;
char *cp_rp;
if (!addr_valid (_T("host_inet_addr"), cp, 4))
if (!trap_valid_address(ctx, cp, 4))
return 0;
cp_rp = (char*)get_real_address (cp);
cp_rp = trap_get_alloc_string(ctx, cp, 256);
addr = htonl(inet_addr(cp_rp));
if (ISBSDTRACE) {
TCHAR *s = au (cp_rp);
BSDTRACE((_T("inet_addr(%s) -> 0x%08lx\n"),s,addr));
BSDTRACE((_T("inet_addr(%s) -> 0x%08lx\n"), s, addr));
xfree (s);
}
xfree(cp_rp);
return addr;
}
@ -2560,12 +2562,15 @@ void host_getprotobyname(TrapContext *ctx, SB, uae_u32 name)
argsp->sb = sb;
argsp->wscnt = ++wscounter;
name_rp = "";
if (addr_valid (_T("host_gethostbynameaddr"), name, 1))
name_rp = (char*)get_real_address (name);
name_rp = NULL;
if (ISBSDTRACE) {
if (trap_valid_address(ctx, name, 1)) {
name_rp = trap_get_alloc_string(ctx, name, 256);
}
}
if (ISBSDTRACE) {
TCHAR *s = au (name_rp);
TCHAR *s = au (name_rp ? name_rp : "");
BSDTRACE((_T("getprotobyname(%s):%d -> "),s, argsp->wscnt));
xfree (s);
}
@ -2586,7 +2591,8 @@ void host_getprotobyname(TrapContext *ctx, SB, uae_u32 name)
size += strlen(p->p_name)+1;
if (p->p_aliases != NULL)
while (p->p_aliases[numaliases]) size += strlen(p->p_aliases[numaliases++])+5;
while (p->p_aliases[numaliases])
size += strlen(p->p_aliases[numaliases++])+5;
if (sb->protoent) {
uae_FreeMem(ctx, sb->protoent, sb->protoentsize, sb->sysbase);
@ -2596,7 +2602,7 @@ void host_getprotobyname(TrapContext *ctx, SB, uae_u32 name)
if (!sb->protoent) {
if (ISBSDTRACE) {
TCHAR *s = au (name_rp);
TCHAR *s = au(name_rp ? name_rp : "");
write_log (_T("BSDSOCK: WARNING - getprotobyname() ran out of Amiga memory ")
_T("(couldn't allocate %ld bytes) while returning result of lookup for '%s':%d\n"),
size, s, argsp->wscnt);
@ -2609,16 +2615,16 @@ void host_getprotobyname(TrapContext *ctx, SB, uae_u32 name)
sb->protoentsize = size;
aptr = sb->protoent+16+numaliases*4;
aptr = sb->protoent + 16 + numaliases * 4;
// transfer protoent to Amiga memory
put_long (sb->protoent+4,sb->protoent+12);
put_long (sb->protoent+8,p->p_proto);
trap_put_long(ctx, sb->protoent + 4, sb->protoent + 12);
trap_put_long(ctx, sb->protoent + 8, p->p_proto);
for (i = 0; i < numaliases; i++)
put_long (sb->protoent + 12 + i * 4, addstr_ansi(ctx, &aptr, p->p_aliases[i]));
put_long (sb->protoent + 12 + numaliases * 4,0);
put_long (sb->protoent, aptr);
trap_put_long(ctx, sb->protoent + 12 + i * 4, addstr_ansi(ctx, &aptr, p->p_aliases[i]));
trap_put_long(ctx, sb->protoent + 12 + numaliases * 4,0);
trap_put_long(ctx, sb->protoent, aptr);
addstr_ansi(ctx, &aptr, p->p_name);
if (ISBSDTRACE) {
TCHAR *s = au (p->p_name);
@ -2631,6 +2637,7 @@ void host_getprotobyname(TrapContext *ctx, SB, uae_u32 name)
BSDTRACE((_T("failed (%d):%d\n"), sb->sb_errno, argsp->wscnt));
}
xfree(name_rp);
release_get_thread (tindex);
}
@ -2656,16 +2663,22 @@ void host_getservbynameport(TrapContext *ctx, SB, uae_u32 nameport, uae_u32 prot
argsp->wscnt = ++wscounter;
if (proto) {
if (addr_valid (_T("host_getservbynameport1"), proto, 1))
proto_rp = au ((char*)get_real_address (proto));
if (trap_valid_address(ctx, proto, 1)) {
uae_char buf[256];
trap_get_string(ctx, buf, proto, sizeof buf);
proto_rp = au(buf);
}
}
if (type) {
BSDTRACE((_T("getservbyport(%d,%s);%d -> "),nameport, proto_rp ? proto_rp : _T("NULL"), argsp->wscnt));
BSDTRACE((_T("getservbyport(%d,%s);%d -> "), nameport, proto_rp ? proto_rp : _T("NULL"), argsp->wscnt));
} else {
if (addr_valid (_T("host_getservbynameport2"), nameport, 1))
name_rp = au ((char*)get_real_address (nameport));
BSDTRACE((_T("getservbyname(%s,%s):%d -> "),name_rp, proto_rp ? proto_rp : _T("NULL"), argsp->wscnt));
if (trap_valid_address(ctx, nameport, 1)) {
uae_char buf[256];
trap_get_string(ctx, buf, nameport, sizeof buf);
name_rp = au(buf);
}
BSDTRACE((_T("getservbyname(%s,%s):%d -> "), name_rp, proto_rp ? proto_rp : _T("NULL"), argsp->wscnt));
}
argsp->args1 = 2;
@ -2709,19 +2722,19 @@ void host_getservbynameport(TrapContext *ctx, SB, uae_u32 nameport, uae_u32 prot
aptr = sb->servent + 20 + numaliases * 4;
// transfer servent to Amiga memory
put_long (sb->servent + 4, sb->servent + 16);
put_long (sb->servent + 8, (unsigned short)htons(s->s_port));
trap_put_long(ctx, sb->servent + 4, sb->servent + 16);
trap_put_long(ctx, sb->servent + 8, (unsigned short)htons(s->s_port));
for (i = 0; i < numaliases; i++)
put_long (sb->servent + 16 + i * 4,addstr_ansi(ctx, &aptr,s->s_aliases[i]));
put_long (sb->servent + 16 + numaliases * 4,0);
put_long (sb->servent, aptr);
trap_put_long(ctx, sb->servent + 16 + i * 4, addstr_ansi(ctx, &aptr,s->s_aliases[i]));
trap_put_long(ctx, sb->servent + 16 + numaliases * 4,0);
trap_put_long(ctx, sb->servent, aptr);
addstr_ansi(ctx, &aptr, s->s_name);
put_long (sb->servent + 12, aptr);
trap_put_long(ctx, sb->servent + 12, aptr);
addstr_ansi(ctx, &aptr, s->s_proto);
if (ISBSDTRACE) {
TCHAR *ss = au (s->s_name);
TCHAR *ss = au(s->s_name);
BSDTRACE((_T("OK (%s, %d):%d\n"), ss, (unsigned short)htons(s->s_port), argsp->wscnt));
xfree (ss);
}
@ -2735,11 +2748,13 @@ void host_getservbynameport(TrapContext *ctx, SB, uae_u32 nameport, uae_u32 prot
release_get_thread (tindex);
}
uae_u32 host_gethostname(uae_u32 name, uae_u32 namelen)
uae_u32 host_gethostname(TrapContext *ctx, uae_u32 name, uae_u32 namelen)
{
if (!addr_valid (_T("host_gethostname"), name, namelen))
if (!trap_valid_address(ctx, name, namelen))
return -1;
return gethostname ((char*)get_real_address (name),namelen);
uae_char buf[256];
trap_get_string(ctx, buf, name, sizeof buf);
return gethostname(buf, namelen);
}
#endif

View File

@ -3051,11 +3051,11 @@ uae_u8 *target_load_keyfile (struct uae_prefs *p, const TCHAR *path, int *sizep,
int size;
TCHAR *libname = _T("amigaforever.dll");
h = WIN32_LoadLibrary (libname);
h = WIN32_LoadLibrary(libname);
if (!h) {
TCHAR path[MAX_DPATH];
_stprintf (path, _T("%s..\\Player\\%s"), start_path_exe, libname);
h = WIN32_LoadLibrary2 (path);
h = WIN32_LoadLibrary(path);
if (!h) {
TCHAR *afr = _wgetenv (_T("AMIGAFOREVERROOT"));
if (afr) {
@ -3063,7 +3063,7 @@ uae_u8 *target_load_keyfile (struct uae_prefs *p, const TCHAR *path, int *sizep,
_tcscpy (tmp, afr);
fixtrailing (tmp);
_stprintf (path, _T("%sPlayer\\%s"), tmp, libname);
h = WIN32_LoadLibrary2 (path);
h = WIN32_LoadLibrary(path);
}
}
}
@ -4755,7 +4755,8 @@ static void WIN32_HandleRegistryStuff (void)
else
regsetint (NULL, _T("RelativePaths"), relativepaths);
regqueryint (NULL, _T("QuickStartMode"), &quickstart);
if (!regqueryint (NULL, _T("QuickStartMode"), &quickstart))
quickstart = 1;
reopen_console ();
fetch_path (_T("ConfigurationPath"), path, sizeof (path) / sizeof (TCHAR));
path[_tcslen (path) - 1] = 0;
@ -6666,12 +6667,6 @@ HMODULE WIN32_LoadLibrary (const TCHAR *name)
{
return WIN32_LoadLibrary_2 (name, TRUE);
}
HMODULE WIN32_LoadLibrary2 (const TCHAR *name)
{
HMODULE m = LoadLibrary (name);
LLError (m, name);
return m;
}
int isdllversion (const TCHAR *name, int version, int revision, int subver, int subrev)
{

View File

@ -20,12 +20,12 @@
#define LANG_DLL_FULL_VERSION_MATCH 1
#if WINUAEPUBLICBETA
#define WINUAEBETA _T("5")
#define WINUAEBETA _T("6")
#else
#define WINUAEBETA _T("")
#endif
#define WINUAEDATE MAKEBD(2016, 2, 10)
#define WINUAEDATE MAKEBD(2016, 2, 14)
//#define WINUAEEXTRA _T("AmiKit Preview")
//#define WINUAEEXTRA _T("Amiga Forever Edition")
@ -156,7 +156,6 @@ void associate_file_extensions (void);
#define WIN32_PLUGINDIR _T("plugins\\")
HMODULE WIN32_LoadLibrary (const TCHAR *);
HMODULE WIN32_LoadLibrary2 (const TCHAR *);
int isdllversion (const TCHAR *name, int version, int revision, int subver, int subrev);
extern int screenshot_prepare (void);

View File

@ -1,8 +1,20 @@
Beta 6:
- Fixed uaehf.device and input on the fly device change invalid free() calls.
- Game Ports panel autofire/joystick type setting was not remembered.
- Do not queue new uaenet.device uae_Signal() call if previous is still in queue.
- Do not call any host OS functions from uaegfx trap functions, trap function can run in different thread context
which can cause strange side-effects. OS4.x uaegfx resolution changes should be safe again.
- Added shellexec custom input event/uae-configuration command that can execute Amiga-side commands or scripts.
Uses SystemTagList() with NIL: Input and Output handles if KS2+, Execute() with NIL: Output if pre-KS2.
Only works when UAE Boot ROM is active, dos.library has been initialized and AmigaOS is running normally.
- Display panel color component gamma value calculation fixed, any brightness or contrast modification was too dark.
Beta 5:
- Game Ports mouse and joystick was always reset to defaults (b4)
- Dark palette fix adjustment is now calculated before other adjustments (brightness, contrast, gamme)
- Dark palette fix adjustment is now calculated before other adjustments (brightness, contrast, gamma)
- Dark palette fix third option added, pre-converted Atari ST palette increased to full range, 12-bit EEE becomes
nearly full white, FCFCFC in 24-bit RGB space. (Not FFFFFF because palette would not be linear anymore)
@ -98,7 +110,7 @@ Notes:
- Slower than normal host<>Amiga communication because every read or write that accesses Amiga memory needs to be
done in Amiga side (due to non-1:1 logical/physical mapping). It will never be as fast as direct communication.
- Remember to set ROM panel UAE expansion type to "New UAE (128k, ROM, Indirect)".
- Directory harddrive (copied from HDF) OS4 installation will boot but it is not recommended, it is slowe
- Directory harddrive (copied from HDF) OS4 installation will boot but it is not recommended, it is slower
than HDF and there is mysterious issue that causes random read errors. (Missing font requester when booting is the
most common side-effect)
- Most UAE expansions have preliminary updates for indirect trap support and support required multiple major

View File

@ -425,19 +425,25 @@ static volatile uae_atomic outtrap_alloc[RTAREA_TRAP_DATA_SEND_NUM];
TrapContext *alloc_host_main_trap_context(void)
{
int trap_slot = RTAREA_TRAP_DATA_NUM;
if (atomic_inc(&outtrap_alloc[trap_slot - RTAREA_TRAP_DATA_NUM])) {
while (outtrap_alloc[trap_slot - RTAREA_TRAP_DATA_NUM] > RTAREA_TRAP_DATA_SEND_NUM)
sleep_millis(1);
if (trap_is_indirect()) {
int trap_slot = RTAREA_TRAP_DATA_NUM;
if (atomic_inc(&outtrap_alloc[trap_slot - RTAREA_TRAP_DATA_NUM])) {
while (outtrap_alloc[trap_slot - RTAREA_TRAP_DATA_NUM] > RTAREA_TRAP_DATA_SEND_NUM)
sleep_millis(1);
}
TrapContext *ctx = &outtrap[trap_slot - RTAREA_TRAP_DATA_NUM];
return ctx;
} else {
return NULL;
}
TrapContext *ctx = &outtrap[trap_slot - RTAREA_TRAP_DATA_NUM];
return ctx;
}
void free_host_trap_context(TrapContext *ctx)
{
int trap_slot = RTAREA_TRAP_DATA_NUM;
atomic_dec(&outtrap_alloc[trap_slot]);
if (trap_is_indirect()) {
int trap_slot = RTAREA_TRAP_DATA_NUM;
atomic_dec(&outtrap_alloc[trap_slot]);
}
}
static uae_u32 call_hardware_trap_back_back(TrapContext *ctx, uae_u16 cmd, uae_u32 p1, uae_u32 p2, uae_u32 p3, uae_u32 p4)
@ -520,6 +526,24 @@ void trap_callback(TRAP_CALLBACK cb, void *ud)
}
}
TrapContext *alloc_host_thread_trap_context(void)
{
if (trap_is_indirect()) {
int trap_slot = RTAREA_TRAP_DATA_NUM;
TrapContext *ctx = alloc_host_main_trap_context();
ctx->host_trap_data = rtarea_bank.baseaddr + RTAREA_TRAP_DATA + trap_slot * RTAREA_TRAP_DATA_SLOT_SIZE;
ctx->amiga_trap_data = rtarea_base + RTAREA_TRAP_DATA + trap_slot * RTAREA_TRAP_DATA_SLOT_SIZE;
ctx->host_trap_status = rtarea_bank.baseaddr + RTAREA_TRAP_STATUS + trap_slot * RTAREA_TRAP_STATUS_SIZE;
ctx->amiga_trap_status = rtarea_base + RTAREA_TRAP_STATUS + trap_slot * RTAREA_TRAP_STATUS_SIZE;
// Set status to allocated, we are skipping hwtrap_entry()
put_long_host(ctx->host_trap_status + 4, 0x00000000);
put_long_host(ctx->host_trap_status, 0x00000080);
return ctx;
} else {
return NULL;
}
}
/*
* Set up extended trap context and call handler function
@ -1189,6 +1213,13 @@ int trap_get_string(TrapContext *ctx, void *haddrp, uaecptr addr, int maxlen)
}
return len;
}
uae_char *trap_get_alloc_string(TrapContext *ctx, uaecptr addr, int maxlen)
{
uae_char *buf = xmalloc(uae_char, maxlen);
trap_get_string(ctx, buf, addr, maxlen);
return buf;
}
int trap_get_bstr(TrapContext *ctx, uae_u8 *haddr, uaecptr addr, int maxlen)
{
int len = 0;