void trap_memcpyha_safe(TrapContext *ctx, uaecptr dst, const uae_u8 *src, int size) { if (size <= 0) return; if (trap_is_indirect()) { trap_put_bytes(ctx, src, dst, size); } else { memcpyha_safe(dst, src, size); } }
static int handleread (TrapContext *ctx, struct priv_s2devstruct *pdev, uaecptr request, uae_u8 *d, int len, int cmd) { uae_u8 flags = get_byte (request + 30); uaecptr data = get_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2 + 4); uaecptr srcaddr = request + 32 + 4 + 4; uaecptr dstaddr = request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES; uae_u16 type = (d[2 * ADDR_SIZE] << 8) | d[2 * ADDR_SIZE + 1]; uae_u32 v = 0; uaecptr data2; memcpyha_safe (pdev->tempbuf, d, len); memcpyha_safe (dstaddr, d, ADDR_SIZE); memcpyha_safe (srcaddr, d + ADDR_SIZE, ADDR_SIZE); put_long (request + 32 + 4, type); if (pdev->tracks[type]) { pdev->bytesreceived += len; pdev->packetsreceived++; } flags &= ~(SANA2IOF_BCAST | SANA2IOF_MCAST); if (isbroadcast (d)) flags |= SANA2IOF_BCAST; else if (ismulticast (d)) flags |= SANA2IOF_MCAST; put_byte (request + 30, flags); data2 = pdev->tempbuf; if (!(flags & SANA2IOF_RAW)) { len -= ETH_HEADER_SIZE; data2 += ETH_HEADER_SIZE; } put_long (request + 32 + 4 + 4 + SANA2_MAX_ADDR_BYTES * 2, len); if (pdev->packetfilter && cmd == CMD_READ && packetfilter (ctx, pdev->packetfilter, request, data2) == 0) return 0; if (!copytobuff (ctx, data2, data, len, pdev->copytobuff)) { put_long (request + 32, S2WERR_BUFF_ERROR); put_byte (request + 31, S2ERR_NO_RESOURCES); } return 1; }