mirror of
https://github.com/ivoszbg/uniLoader.git
synced 2024-11-10 06:00:07 +00:00
main: Use built-in memcpy
Signed-off-by: Markuss Broks <markuss.broks@gmail.com>
This commit is contained in:
parent
7ce00a6ed2
commit
3643d6a0c8
@ -3,6 +3,8 @@
|
|||||||
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
* Copyright (c) 2022, Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifndef MAIN_H_ /* Include guard */
|
#ifndef MAIN_H_ /* Include guard */
|
||||||
#define MAIN_H_
|
#define MAIN_H_
|
||||||
|
|
||||||
@ -13,14 +15,35 @@ extern void board_init(void);
|
|||||||
|
|
||||||
extern void printk(char *text);
|
extern void printk(char *text);
|
||||||
|
|
||||||
/* Define our own 128 bit memcpy */
|
#ifndef __has_builtin
|
||||||
void memcpy(void *dest, void *src, int size)
|
#define __has_builtin(x) 0
|
||||||
{
|
#endif
|
||||||
unsigned __int128 *src2 = src;
|
|
||||||
unsigned __int128 *dest2 = dest;
|
#if __has_builtin(__builtin_memcpy)
|
||||||
|
void memcpy(void *dest, void *src, size_t size) {
|
||||||
|
__builtin_memcpy(dest, src, size);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#ifdef __aarch64__
|
||||||
|
/* Define our own 128 bit memcpy */
|
||||||
|
void memcpy(void *dest, void *src, size_t size)
|
||||||
|
{
|
||||||
|
unsigned __int128 *src2 = src;
|
||||||
|
unsigned __int128 *dest2 = dest;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size / 16; i++)
|
||||||
|
dest2[i] = src2[i];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __arm__
|
||||||
|
void memcpy (char* src, char* dest, size_t len) {
|
||||||
|
for (size_t i = 0; i < len; i++)
|
||||||
|
dest[i] = src[i];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
for (int i=0; i<size/16; i++)
|
|
||||||
dest2[i] = src2[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // MAIN_H_
|
#endif // MAIN_H_
|
||||||
|
@ -17,6 +17,6 @@ void main(void* dt, void* kernel) {
|
|||||||
|
|
||||||
/* Copy kernel to memory and boot */
|
/* Copy kernel to memory and boot */
|
||||||
printk("Booting linux...");
|
printk("Booting linux...");
|
||||||
memcpy((void*)CONFIG_PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size);
|
__builtin_memcpy((void*)CONFIG_PAYLOAD_ENTRY, kernel, (unsigned long) &kernel_size);
|
||||||
load_kernel(dt, 0, 0, 0, (void*)CONFIG_PAYLOAD_ENTRY);
|
load_kernel(dt, 0, 0, 0, (void*)CONFIG_PAYLOAD_ENTRY);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user