Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/dreamcast/dev/microcode arm side of aica(4) sometim...
details: https://anonhg.NetBSD.org/src/rev/3debd253bfca
branches: trunk
changeset: 370733:3debd253bfca
user: ryo <ryo%NetBSD.org@localhost>
date: Sun Sep 25 21:19:20 2022 +0000
description:
arm side of aica(4) sometimes became unresponsive when audioplay was performed several times.
- disabled data cache at startup.
- compiled with cross-arm-none-eabi-gcc-8.3.0nb4 of pkg.
- added memset() in asm because gcc8 (and later) detects the zero clear part in
own bzero function and calls memset internally, and bzero were replaced with memset.
diffstat:
sys/arch/dreamcast/dev/microcode/Makefile | 9 +-
sys/arch/dreamcast/dev/microcode/aica_arm.c | 45 +-
sys/arch/dreamcast/dev/microcode/aica_arm_locore.S | 34 +-
sys/arch/dreamcast/dev/microcode/aica_armcode.h | 2190 +++++++++----------
4 files changed, 1134 insertions(+), 1144 deletions(-)
diffs (truncated from 2375 to 300 lines):
diff -r 07975c224daf -r 3debd253bfca sys/arch/dreamcast/dev/microcode/Makefile
--- a/sys/arch/dreamcast/dev/microcode/Makefile Sun Sep 25 17:52:25 2022 +0000
+++ b/sys/arch/dreamcast/dev/microcode/Makefile Sun Sep 25 21:19:20 2022 +0000
@@ -1,15 +1,16 @@
-# $NetBSD: Makefile,v 1.5 2019/05/06 17:12:50 ryo Exp $
+# $NetBSD: Makefile,v 1.6 2022/09/25 21:19:20 ryo Exp $
S = ${.CURDIR}/../../../..
-CC = ${TOOLDIR}/bin/arm--netbsdelf-gcc
-OBJCOPY = ${TOOLDIR}/bin/arm--netbsdelf-objcopy
+TOOLDIR ?= /usr/pkg/cross-arm-none-eabi
+
+CC = ${TOOLDIR}/bin/arm-none-eabi-gcc
+OBJCOPY = ${TOOLDIR}/bin/arm-none-eabi-objcopy
CFLAGS = -W -Wall -mlittle-endian
CFLAGS += -O3 -mcpu=arm7
CFLAGS += -fomit-frame-pointer -funroll-loops -finline-functions
CFLAGS += -I${S}
-#AFLAGS = -mcpu=arm7tdmi -mthumb -mthumb-interwork -mapcs-32
all: aica_armcode.h
diff -r 07975c224daf -r 3debd253bfca sys/arch/dreamcast/dev/microcode/aica_arm.c
--- a/sys/arch/dreamcast/dev/microcode/aica_arm.c Sun Sep 25 17:52:25 2022 +0000
+++ b/sys/arch/dreamcast/dev/microcode/aica_arm.c Sun Sep 25 21:19:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aica_arm.c,v 1.6 2019/05/06 17:12:50 ryo Exp $ */
+/* $NetBSD: aica_arm.c,v 1.7 2022/09/25 21:19:20 ryo Exp $ */
/*
* Copyright (c) 2003 SHIMIZU Ryo <ryo%misakimix.org@localhost>
@@ -56,11 +56,11 @@
#define CH_WRITE_2(ch,off,val) REG_WRITE_2(((ch) << 7) + (off), val)
#define CH_WRITE_4(ch,off,val) REG_WRITE_4(((ch) << 7) + (off), val)
+void *memset(void *, int, unsigned long);
+
void aica_init(void);
inline int in_first_half(unsigned int);
inline int in_second_half(unsigned int);
-void bzero_4(void *, unsigned int);
-void bzero(void *, unsigned int);
uint32_t rate2reg(unsigned int);
void aica_stop(void);
void aica_main(void);
@@ -120,29 +120,6 @@
return REG_READ_4(0x2814) >= loophalf;
}
-
-void
-bzero_4(void *b, unsigned int len)
-{
- uint32_t *p;
-
- p = b;
- len = (len + 3) & ~3;
- for (; len != 0; len -= 4)
- *p++ = 0;
-}
-
-void
-bzero(void *b,unsigned int len)
-{
- uint8_t *p;
-
- p = b;
- for (; len != 0; len--)
- *p++ = 0;
-}
-
-
uint32_t
rate2reg(unsigned int rate)
{
@@ -197,8 +174,8 @@
CH_WRITE_4(0, 0x00, 0x8000);
CH_WRITE_4(1, 0x00, 0x8000);
- bzero_4((void *)AICA_DMABUF_LEFT, AICA_DMABUF_SIZE);
- bzero_4((void *)AICA_DMABUF_RIGHT, AICA_DMABUF_SIZE);
+ memset((void *)AICA_DMABUF_LEFT, 0, AICA_DMABUF_SIZE);
+ memset((void *)AICA_DMABUF_RIGHT, 0, AICA_DMABUF_SIZE);
}
void
@@ -214,8 +191,8 @@
REG_WRITE_4(0x28b4, 0x0020); /* INT Enable to SH4 */
- bzero_4((void *)AICA_DMABUF_LEFT, AICA_DMABUF_SIZE);
- bzero_4((void *)AICA_DMABUF_RIGHT, AICA_DMABUF_SIZE);
+ memset((void *)AICA_DMABUF_LEFT, 0, AICA_DMABUF_SIZE);
+ memset((void *)AICA_DMABUF_RIGHT, 0, AICA_DMABUF_SIZE);
play_state = 0;
serial = aicacmd->serial = 0;
@@ -348,15 +325,15 @@
case AICA_COMMAND_STOP:
switch (play_state) {
case 1:
- bzero_4((void *)(AICA_DMABUF_LEFT + blksize),
+ memset((void *)(AICA_DMABUF_LEFT + blksize), 0,
blksize);
- bzero_4((void *)(AICA_DMABUF_RIGHT + blksize),
+ memset((void *)(AICA_DMABUF_RIGHT + blksize), 0,
blksize);
play_state = 3;
break;
case 2:
- bzero_4((void *)AICA_DMABUF_LEFT, blksize);
- bzero_4((void *)AICA_DMABUF_RIGHT, blksize);
+ memset((void *)AICA_DMABUF_LEFT, 0, blksize);
+ memset((void *)AICA_DMABUF_RIGHT, 0, blksize);
play_state = 4;
break;
default:
diff -r 07975c224daf -r 3debd253bfca sys/arch/dreamcast/dev/microcode/aica_arm_locore.S
--- a/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S Sun Sep 25 17:52:25 2022 +0000
+++ b/sys/arch/dreamcast/dev/microcode/aica_arm_locore.S Sun Sep 25 21:19:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aica_arm_locore.S,v 1.3 2019/05/06 17:12:50 ryo Exp $ */
+/* $NetBSD: aica_arm_locore.S,v 1.4 2022/09/25 21:19:20 ryo Exp $ */
/*
* Copyright (c) 2003 SHIMIZU Ryo <ryo%misakimix.org@localhost>
@@ -49,6 +49,11 @@
bic r0,r0,#0x40
msr CPSR_all,r0
+ mrc p15,0,r0,c1,c0,0 /* read control register */
+ bic r0,r0,#0x0004 /* DC disable */
+ orr r0,r0,#0x1000 /* IC enable */
+ mcr p15,0,r0,c1,c0,0 /* write control register */
+
bl aica_main
exp_reserved:
@@ -69,3 +74,30 @@
exp_undef:
mov pc,r14
+ .global memset
+/* memset(void *b:r0, int c:r1, size_t len:r2) */
+memset:
+ /* optimized only if c == 0 and b is 4-byte aligned. */
+ and r3,r0,#3 /* r0 is 4byte aligned ? */
+ orrs r3,r3,r1 /* r1 == 0 ? */
+ mov r3,r0 /* p:r3 = b; */
+ bne .memset_byte
+ add r2,r0,r2 /* e:r2 = b + (len & -4); */
+ bic r2,r2,#3
+.memset32_zero:
+ cmp r3,r2 /* if (e > p) { */
+ bls .memset_byte
+1: /* do { */
+ str r1,[r3],#4 /* *(uint32_t *)p++ = c; */
+ cmp r3,r2 /* while (e < p); */
+ bhi 1b
+ /* } */
+.memset_byte:
+ add r2,r0,r2 /* e:r2 = b + len; */
+ cmp r0,r2 /* if (e > p) return; */
+ movls pc,lr
+1: /* do { */
+ strb r1,[r3],#1 /* *(uint8_t *)p++ = c; */
+ cmp r3,r2 /* while (e < p); */
+ bhi 1b
+ mov pc,lr /* return; */
diff -r 07975c224daf -r 3debd253bfca sys/arch/dreamcast/dev/microcode/aica_armcode.h
--- a/sys/arch/dreamcast/dev/microcode/aica_armcode.h Sun Sep 25 17:52:25 2022 +0000
+++ b/sys/arch/dreamcast/dev/microcode/aica_armcode.h Sun Sep 25 21:19:20 2022 +0000
@@ -1,1115 +1,1095 @@
-/* $NetBSD: aica_armcode.h,v 1.4 2019/05/06 17:12:50 ryo Exp $ */
+/* $NetBSD: aica_armcode.h,v 1.5 2022/09/25 21:19:20 ryo Exp $ */
static uint32_t aica_armcode[] = {
/* 0000 */ 0xea000006,
- /* 0004 */ 0xea000010,
- /* 0008 */ 0xea00000e,
- /* 000c */ 0xea00000c,
- /* 0010 */ 0xea00000a,
- /* 0014 */ 0xea000007,
- /* 0018 */ 0xea000007,
+ /* 0004 */ 0xea000014,
+ /* 0008 */ 0xea000012,
+ /* 000c */ 0xea000010,
+ /* 0010 */ 0xea00000e,
+ /* 0014 */ 0xea00000b,
+ /* 0018 */ 0xea00000b,
/* 001c */ 0xe24ef004,
/* 0020 */ 0xe3a0dcff,
/* 0024 */ 0xe10f0000,
/* 0028 */ 0xe3c00080,
/* 002c */ 0xe3c00040,
/* 0030 */ 0xe129f000,
- /* 0034 */ 0xeb0001b6,
- /* 0038 */ 0xeafffffe,
- /* 003c */ 0xe24ef004,
- /* 0040 */ 0xe24ef008,
- /* 0044 */ 0xe24ef004,
- /* 0048 */ 0xe1a0f00e,
- /* 004c */ 0xe1a0f00e,
- /* 0050 */ 0xe3a00502,
- /* 0054 */ 0xe3a02000,
- /* 0058 */ 0xe2803a02,
- /* 005c */ 0xe52d4004,
- /* 0060 */ 0xe5832800,
- /* 0064 */ 0xe1a01002,
- /* 0068 */ 0xe3a04902,
- /* 006c */ 0xe3a0001f,
- /* 0070 */ 0xe3a0c024,
- /* 0074 */ 0xe1a03381,
- /* 0078 */ 0xe2811001,
- /* 007c */ 0xe2833502,
- /* 0080 */ 0xe3510040,
- /* 0084 */ 0xe5834000,
- /* 0088 */ 0xe5832004,
- /* 008c */ 0xe5832008,
- /* 0090 */ 0xe583200c,
- /* 0094 */ 0xe5830010,
- /* 0098 */ 0xe5830014,
- /* 009c */ 0xe5832018,
- /* 00a0 */ 0xe583201c,
- /* 00a4 */ 0xe5832020,
- /* 00a8 */ 0xe5832024,
- /* 00ac */ 0xe583c028,
- /* 00b0 */ 0xe583202c,
- /* 00b4 */ 0xe5832030,
- /* 00b8 */ 0xe5832034,
- /* 00bc */ 0xe5832038,
- /* 00c0 */ 0xe583203c,
- /* 00c4 */ 0xe5832040,
- /* 00c8 */ 0xe5832044,
- /* 00cc */ 0xe5832048,
- /* 00d0 */ 0xe583204c,
- /* 00d4 */ 0xe5832050,
- /* 00d8 */ 0xe5832054,
- /* 00dc */ 0xe5832058,
- /* 00e0 */ 0xe583205c,
- /* 00e4 */ 0xe5832060,
- /* 00e8 */ 0xe5832064,
- /* 00ec */ 0xe5832068,
- /* 00f0 */ 0xe583206c,
- /* 00f4 */ 0xe5832070,
- /* 00f8 */ 0xe5832074,
- /* 00fc */ 0xe5832078,
- /* 0100 */ 0xe583207c,
- /* 0104 */ 0x1affffda,
- /* 0108 */ 0xe3a0c502,
- /* 010c */ 0xe28c1a02,
- /* 0110 */ 0xe3a0200f,
- /* 0114 */ 0xe5812800,
- /* 0118 */ 0xe8bd0010,
- /* 011c */ 0xe1a0f00e,
- /* 0120 */ 0xe3a0c502,
- /* 0124 */ 0xe28c2b0a,
- /* 0128 */ 0xe3a03000,
- /* 012c */ 0xe5c2300d,
- /* 0130 */ 0xe28c1a02,
- /* 0134 */ 0xe5913814,
- /* 0138 */ 0xe1530000,
- /* 013c */ 0x23a00000,
- /* 0140 */ 0x33a00001,
- /* 0144 */ 0xe1a0f00e,
- /* 0148 */ 0xe3a0c502,
- /* 014c */ 0xe28c2b0a,
- /* 0150 */ 0xe3a03000,
- /* 0154 */ 0xe5c2300d,
- /* 0158 */ 0xe28c1a02,
- /* 015c */ 0xe5913814,
- /* 0160 */ 0xe1530000,
- /* 0164 */ 0x33a00000,
- /* 0168 */ 0x23a00001,
- /* 016c */ 0xe1a0f00e,
- /* 0170 */ 0xe2813003,
- /* 0174 */ 0xe3d33003,
- /* 0178 */ 0xe92d05f0,
- /* 017c */ 0x0a000036,
- /* 0180 */ 0xe2432004,
- /* 0184 */ 0xe1a0c122,
- /* 0188 */ 0xe3a01000,
- /* 018c */ 0xe3530004,
- /* 0190 */ 0xe20cc007,
- /* 0194 */ 0xe7801001,
- /* 0198 */ 0xe3a02004,
- /* 019c */ 0x0a00002e,
- /* 01a0 */ 0xe35c0000,
- /* 01a4 */ 0x0a00001a,
- /* 01a8 */ 0xe35c0001,
- /* 01ac */ 0x0a000014,
- /* 01b0 */ 0xe35c0002,
- /* 01b4 */ 0x0a000010,
- /* 01b8 */ 0xe35c0003,
- /* 01bc */ 0x0a00000c,
- /* 01c0 */ 0xe35c0004,
- /* 01c4 */ 0x0a000008,
- /* 01c8 */ 0xe35c0005,
- /* 01cc */ 0x0a000004,
Home |
Main Index |
Thread Index |
Old Index