On 18/06/2020 01:25, Allan Peramaki wrote:
On 17/06/2020 23:23, Peter Maydell wrote:
Are these accesses all guaranteed to be correctly aligned
to be 16 or 32 bit loads/stores ? Otherwise it would be
better to use the ldl_p/stl_p/ldw_p/stw_p/etc accessors,
which correctly handle possibly misaligned pointers.
Yes (assuming compiler aligns struct fields properly.) It is not obvious
though (and easy to break), so I suppose refactoring much of the GUS
code would be nice. For example, the few places where GUSregd(position)
is used, position is 2 (mod 4). On the other hand, gusptr is also 2 (mod
4) bytes (making gusptr+position = 0 (mod 4)), because we have the struct
It is aligned, but my reasoning had a mistake. Both gusptr and position
(GUSDRAMPOS24bit and voicewavetableirq) are 0 (mod 4). (mixbuf is a
pointer.) Sorry.
typedef struct GUSState {
ISADevice dev;
GUSEmuState emu;
QEMUSoundCard card;
uint32_t freq;
uint32_t port;
int pos, left, shift, irqs;
int16_t *mixbuf;
uint8_t himem[1024 * 1024 + 32 + 4096];
int samples;
SWVoiceOut *voice;
int64_t last_ticks;
qemu_irq pic;
IsaDma *isa_dma;
PortioList portio_list1;
PortioList portio_list2;
} GUSState;
Best regards,
Allan