difos/target/linux/realtek/image/rt-loader/include/memory.h
Markus Stockhausen ccbff8bbdd realtek: add rt-loader (runtime loader)
The bootloader of many Realtek switches only supports gzipped kernel images.
With limited flash space that might get critical in future versions. For better
compression allow support for compressed images. For this a new loader was
developed. Several ideas have been taken over from the existing lzma loader
but this has been enhanced to make integration simpler. What is new:

- Loader is position independent. No need to define load addresses
- Loader identifies device memory on its own
- Loader uses "official" upstream kernel lzma uncompress
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/decompress_unlzma.c
- Loader uses "official" UNMODIFIED nanoprintg that is used by several
  bare metal projects. https://github.com/charlesnicholson/nanoprintf

Compiled the loader ist just under 12KiB and during boot it will show:

rt-loader
Found RTL8380M (chip id 6275C) with 256MB
Relocate 2924240 bytes from 0x80100000 to 0x8fce0000
Extract kernel with 2900144 bytes from 0x8fce521c to 0x80100000...
Extracted kernel size is 9814907 bytes
Booting kernel from 0x80100000 ...

[    0.000000] Linux version 6.12.33 ...
[    0.000000] RTL838X model is 83806800
...

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/18397
Signed-off-by: Robert Marko <robimarko@gmail.com>
2025-06-28 16:14:55 +02:00

30 lines
761 B
C

/*
* rt-loader header
* (c) 2025 Markus Stockhausen
*/
#ifndef _MEMORY_H_
#define _MEMORY_H_
#include <stddef.h>
#include "globals.h"
#define CACHE_HIT_INVALIDATE_I 0x10
#define CACHE_HIT_WRITEBACK_INV_D 0x15
#define ioread32(reg) (*(volatile int *)(reg))
#define iowrite32(val, reg) (*(volatile int *)(reg) = val)
void flush_cache(void *start_addr, unsigned long size);
void free(void *ptr);
void *malloc(size_t size);
int memcmp(const void *s1, const void *s2, size_t count);
void *memmove(void *dst, const void *src, size_t count);
void *memcpy(void *dst, const void *src, size_t count);
void *memset(void *dst, int value, size_t count);
size_t strlen(const char *s);
extern void *_heap_addr;
extern void *_heap_addr_max;
#endif // _MEMORY_H_