ñmatch malloc,link memtrk

This commit is contained in:
Prakxo
2023-03-06 20:27:17 +01:00
parent e6af76e289
commit 771ffca329
11 changed files with 212 additions and 123 deletions
+7 -7
View File
@@ -6,13 +6,13 @@ __declspec(section ".init") void* TRK_memset(void* dst, int val, size_t size){
return dst;
}
__declspec(section ".init") void* TRK_memcpy(void* dst, const void* src, size_t size){
const u8* s = (const u8*)src -1;
u8* d = (u8*)dst -1;
__declspec(section ".init") void *TRK_memcpy(void *dst, const void *src, size_t n)
{
const unsigned char *s = (const unsigned char *)src - 1;
unsigned char *d = (unsigned char *)dst - 1;
size++;
while(--size != 0){
n++;
while (--n != 0)
*++d = *++s;
return dst;
}
}
}
+12 -14
View File
@@ -6,6 +6,8 @@
__declspec(section ".init")void __init_registers(void);
__declspec(section ".init")void __init_data(void);
int main(int argc, char **argv);
__declspec(section ".init") void __check_pad3(void){
if((*(u16*)0x800030E4 & 0xEEF) == 0xEEF){
OSResetSystem(0,0,0);
@@ -117,26 +119,22 @@ __declspec(section ".init") asm void __init_registers(void){
ori r13, r13, 0xFB80
blr
}
__declspec(section ".init") static void __copy_rom_section(void* dst, const void* src, size_t size){
if (size == 0 || dst == src){
return;
}
void __copy_rom_section(void* dst, const void* src, size_t size){
if (size && (dst != src)) {
memcpy(dst, src, size);
(dst, size);
__flush_cache(dst, size);
}
}
__declspec(section ".init") static void __init_bss_section(void* dst, size_t size){
if(size == 0){
return;
}
void __init_bss_section(void* dst, size_t size){
if (size) {
memset(dst, 0, size);
}
}
__declspec(section ".init") static void __init_data(void){
const RomSection* rs;
const BssSection* bs;
RomSection* rs;
BssSection* bs;
rs = _rom_copy_info;
while (1) {
@@ -157,4 +155,4 @@ __declspec(section ".init") static void __init_data(void){
__init_bss_section(bs->virtualOfs, bs->size);
bs++;
}
}
}
+25
View File
@@ -0,0 +1,25 @@
#include "libc64/osmalloc.h"
extern Arena malloc_arena;
void* malloc(size_t size) {
return(__osMalloc(&malloc_arena, size));
}
void free(void* ptr){
__osFree(&malloc_arena,ptr);
}
void DisplayArena(void){
__osDisplayArena(&malloc_arena);
}
void GetFreeArena(u32* max, u32* free, u32* alloc){
__osGetFreeArena(&malloc_arena, max, free, alloc);
}
void MallocInit(void* start, u32 size){
__osMallocInit(&malloc_arena, start, size);
}
void MallocCleanup(void){
__osMallocCleanup(&malloc_arena);
}