A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * This file was originally part of the Linux/MIPS GNU C Library
11 * Copyright (C) 1998 by Ralf Baechle
12 * Adapted for Rockbox by Maurus Cuelenaere, 2009
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#include "config.h"
25#include "mips.h"
26
27#define FILL64(dst, offset, val) \
28 sw val, (offset + 0x00)(dst); \
29 sw val, (offset + 0x04)(dst); \
30 sw val, (offset + 0x08)(dst); \
31 sw val, (offset + 0x0c)(dst); \
32 sw val, (offset + 0x10)(dst); \
33 sw val, (offset + 0x14)(dst); \
34 sw val, (offset + 0x18)(dst); \
35 sw val, (offset + 0x1c)(dst); \
36 sw val, (offset + 0x20)(dst); \
37 sw val, (offset + 0x24)(dst); \
38 sw val, (offset + 0x28)(dst); \
39 sw val, (offset + 0x2c)(dst); \
40 sw val, (offset + 0x30)(dst); \
41 sw val, (offset + 0x34)(dst); \
42 sw val, (offset + 0x38)(dst); \
43 sw val, (offset + 0x3c)(dst);
44
45#define FILL 64
46#define F_FILL FILL64
47
48#ifdef ROCKBOX_BIG_ENDIAN
49# define SWHI swl /* high part is left in big-endian */
50# define SWLO swr
51#else
52# define SWHI swr /* high part is right in little-endian */
53# define SWLO swl
54#endif
55
56/*
57 * memset(void *s, int c, size_t n)
58 *
59 * a0: start of area to clear
60 * a1: char to fill with
61 * a2: size of area to clear
62 */
63 .section .icode, "ax", %progbits
64
65 .global memset
66 .type memset, %function
67
68 .set noreorder
69 .align 5
70memset:
71 beqz a1, 1f
72 move v0, a0 /* result */
73
74 andi a1, 0xff /* spread fillword */
75 sll t1, a1, 8
76 or a1, t1
77 sll t1, a1, 16
78 or a1, t1
791:
80
81 sltiu t0, a2, 4 /* very small region? */
82 bnez t0, small_memset
83 andi t0, a0, 3 /* aligned? */
84
85 beqz t0, 1f
86 subu t0, 4 /* alignment in bytes */
87
88 SWHI a1, (a0) /* make word aligned */
89 subu a0, t0 /* word align ptr */
90 addu a2, t0 /* correct size */
91
921: ori t1, a2, (FILL-1) /* # of full blocks */
93 xori t1, (FILL-1)
94 beqz t1, memset_partial /* no block to fill */
95 andi t0, a2, (FILL-4)
96
97 addu t1, a0 /* end address */
98 .set reorder
991: addiu a0, FILL
100 F_FILL( a0, -FILL, a1 )
101 bne t1, a0, 1b
102 .set noreorder
103
104memset_partial:
105 la t1, 2f /* where to start */
106 subu t1, t0
107 jr t1
108 addu a0, t0 /* dest ptr */
109
110 F_FILL( a0, -FILL, a1 ) /* ... but first do words ... */
1112: andi a2, 3 /* 0 <= n <= 3 to go */
112
113 beqz a2, 1f
114 addu a0, a2 /* What's left */
115 SWLO a1, -1(a0)
1161: jr ra
117 move a2, zero
118
119small_memset:
120 beqz a2, 2f
121 addu t1, a0, a2
122
1231: addiu a0, 1 /* fill bytewise */
124 bne t1, a0, 1b
125 sb a1, -1(a0)
126
1272: jr ra /* done */
128 move a2, zero
129
130 .set reorder