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>
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef MAIN_H_ /* Include guard */
|
||||
#define MAIN_H_
|
||||
|
||||
@ -13,14 +15,35 @@ extern void board_init(void);
|
||||
|
||||
extern void printk(char *text);
|
||||
|
||||
#ifndef __has_builtin
|
||||
#define __has_builtin(x) 0
|
||||
#endif
|
||||
|
||||
#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, int size)
|
||||
void memcpy(void *dest, void *src, size_t size)
|
||||
{
|
||||
unsigned __int128 *src2 = src;
|
||||
unsigned __int128 *dest2 = dest;
|
||||
|
||||
for (int i=0; i<size/16; i++)
|
||||
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
|
||||
|
||||
|
||||
|
||||
#endif // MAIN_H_
|
||||
|
@ -17,6 +17,6 @@ void main(void* dt, void* kernel) {
|
||||
|
||||
/* Copy kernel to memory and boot */
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user