Skip to content

Commit dc4d7b3

Browse files
frantonyralfbaechle
authored andcommitted
MIPS: ZBOOT: gather string functions into string.c
In the worst case this adds less then 128 bytes of code but on the other hand this makes code organization more clear. Signed-off-by: Antony Pavlov <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Cc: [email protected] Cc: Ralf Baechle <[email protected]> Cc: John Crispin <[email protected]> Cc: Florian Fainelli <[email protected]> Acked-by: Florian Fainelli <[email protected]> Signed-off-by: John Crispin <[email protected]> Patchwork: http://patchwork.linux-mips.org/patch/6344/
1 parent dfe0924 commit dc4d7b3

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

arch/mips/boot/compressed/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
2727
-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \
2828
-DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS)
2929

30-
targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o
30+
targets := head.o decompress.o string.o dbg.o uart-16550.o uart-alchemy.o
3131

3232
# decompressor objects (linked with vmlinuz)
33-
vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
33+
vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/dbg.o
3434

3535
ifdef CONFIG_DEBUG_ZBOOT
3636
vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o

arch/mips/boot/compressed/decompress.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,11 @@ void error(char *x)
4343
/* activate the code for pre-boot environment */
4444
#define STATIC static
4545

46-
#if defined(CONFIG_KERNEL_GZIP) || defined(CONFIG_KERNEL_XZ) || \
47-
defined(CONFIG_KERNEL_LZ4)
48-
void *memcpy(void *dest, const void *src, size_t n)
49-
{
50-
int i;
51-
const char *s = src;
52-
char *d = dest;
53-
54-
for (i = 0; i < n; i++)
55-
d[i] = s[i];
56-
return dest;
57-
}
58-
#endif
5946
#ifdef CONFIG_KERNEL_GZIP
6047
#include "../../../../lib/decompress_inflate.c"
6148
#endif
6249

6350
#ifdef CONFIG_KERNEL_BZIP2
64-
void *memset(void *s, int c, size_t n)
65-
{
66-
int i;
67-
char *ss = s;
68-
69-
for (i = 0; i < n; i++)
70-
ss[i] = c;
71-
return s;
72-
}
7351
#include "../../../../lib/decompress_bunzip2.c"
7452
#endif
7553

arch/mips/boot/compressed/string.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* arch/mips/boot/compressed/string.c
3+
*
4+
* Very small subset of simple string routines
5+
*/
6+
7+
#include <linux/types.h>
8+
9+
void *memcpy(void *dest, const void *src, size_t n)
10+
{
11+
int i;
12+
const char *s = src;
13+
char *d = dest;
14+
15+
for (i = 0; i < n; i++)
16+
d[i] = s[i];
17+
return dest;
18+
}
19+
20+
void *memset(void *s, int c, size_t n)
21+
{
22+
int i;
23+
char *ss = s;
24+
25+
for (i = 0; i < n; i++)
26+
ss[i] = c;
27+
return s;
28+
}

0 commit comments

Comments
 (0)