Commit Graph

215 Commits

Author SHA1 Message Date
Ivaylo Ivanov
04a3e00bd3 drivers: introduce probe-based driver framework
The current drivers/framework.c is useless, as REGISTER_DRIVER() is a macro
that just directly calls the driver probe function. Every board file has to
reference each driver's probe function by name. This was just done to make room
for proper driver probing in the future, where we are now, so implement that.

Make drivers self-register at link time by emitting a struct driver into a
.uniloader_drivers section via DRIVER_REGISTER(). The linker brackets
the section with __drivers_start / __drivers_end symbols.

Boards describe their hardware as a static struct with the format
{ driver_name, plat_data, label }. Remove the drivers_init hook from
struct board_ops as it's no longer necessary.

The drivers probe will now be placed between early_init and splash.
The framework looks up each device's driver_name up in the
linker section and calls probe(plat_data). A failed probe is logged.

Do --whole-archive as well to convince the linker to not drop the drivers
in archived .o files that aren't called outside the archive.

Adopt all boards to use the framework.

All of the changes in this commit are co-dependent on each other, as we're
doing a large change to the ABI.
2026-05-28 00:02:41 +03:00
Ivaylo Ivanov
e71ad3b705 lib: simplefb: make get_font_scale_factor run only if simplefb probed
get_font_scale_factor() unconditionally dereferences fb_info and debug.c's
fb_output() calls get_font_scale_factor() on each printk call, even before
we have simplefb registered. As __simplefb_raw_print has a check if we're
past simplefb probe (fb_info is filled), do the same for get_font_scale_factor()
and return 1 (not scaled) if the struct is not filled.
2026-05-28 00:01:44 +03:00
Ivaylo Ivanov
3c90e2b35f lib: simplefb: name the text top-padding constant
The value 5 appeared bare in two places: simplefb.c (when text wraps
past the bottom of the screen) and debug.c (initial y position for
the printk overlay). Replace both with FB_TEXT_TOP_PADDING defined
once in simplefb.h.
2026-05-28 00:01:44 +03:00
Ivaylo Ivanov
4b386dc15c lib: simplefb: drop redundant variable in scale calculation 2026-05-28 00:01:44 +03:00
Ivaylo Ivanov
b2a3304179 arch: discard runtime-unused metadata sections
The toolchain emits several sections that have no meaning for a flat
binary bootloader:

  .eh_frame             DWARF unwind tables (we never unwind)
  .note.gnu.property    BTI/PAC ELF markers (lost at objcopy)
  .note.gnu.build-id    debug identity (lost at objcopy)
  .comment              compiler version string
  .ARM.attributes       ABI metadata

Gcc emits roughly 7-8 KB of .eh_frame by default for a build of this
size; the others are smaller but equally pointless. Just drop all of
them in the linker scripts.

Net effect on dreamlte_defconfig w/ empty embedded blobs:
61960 -> ~54000 bytes. Stonks.
2026-05-28 00:01:44 +03:00
Ivaylo Ivanov
89ead8a57a arch: aarch64: align .{rodata,data,bss} to 8 bytes
ALIGN(4) is left over from 32-bit linker script templates. On
aarch64 the natural pointer/long alignment is 8, and these sections
usually contain 64-bit constants (pointer tables, 64-bit literals). The
4-byte alignment was harmless because the linker happens to align
individual symbols anyway, but let's just align it properly for the
sake of correctness. For BSS also ensure we have extra padding before
the end of the section.
2026-05-28 00:00:29 +03:00
Ivaylo Ivanov
b6ca1fc1ff board: include string.h directly for boards that use its functions
Several boards call readl()/writel() or use uint32_t but do not include
<string.h> (which is where unic declares these). They build today only
because <drivers/framework.h> pulls <string.h> in.

The framework header has no business pulling string.h; Include it properly
in case we remove framework.h later on (spoiler lol).
2026-05-27 23:45:21 +03:00
Ivaylo Ivanov
6e0c18ae24 board: Add support for Sony Xperia XZ1 Compact
Framebuffer worked first try, unlike taimen.
2026-05-27 17:26:32 +02:00
Ivaylo Ivanov
56f8caa1fa arch: aarch64: Fix up the Linux kernel image header
The current header implementation is incomplete: the text_offset and
image_size slots are overlaid with internal relocation metadata
(_rel_stack_base / _rel_stack_size), and the flags field is zero,
which makes some bootloaders unhappy. Fill up the the missing props and
while at it, stub out the image header into a header file to avoid duplicating.

image_size is computed in the linker script as _stack_end - _start
so the early stack page is included in the runtime memory footprint
advertised to the previous-stage bootloader.

Patch inspired by work from @Trijal08 and cleaned up to not account for
ELF PiE.
2026-05-27 17:26:32 +02:00
Umer Uddin
673a070d36 board: samsung: j4lte: Migrate FB format to ARGB8888
This is the correct format considering commit 61bb212.

Signed-off-by: Umer Uddin <umer.uddin@mentallysanemainliners.org>
2026-05-27 13:09:52 +03:00
Umer Uddin
fe084d4afe boards: sony: board-vita: Migrate FB format to ABGR8888
This is the correct format considering the BGRA write format was wrong before, leading it to actually use ABGR.

Signed-off-by: Umer Uddin <umer.uddin@mentallysanemainliners.org>
2026-05-27 13:09:52 +03:00
Umer Uddin
baaf7d1204 boards: itel: board-p682lpn: Migrate FB format to ABGR8888
This is the correct format considering the BGRA write format was wrong before, leading it to actually use ABGR.

Signed-off-by: Umer Uddin <umer.uddin@mentallysanemainliners.org>
2026-05-27 13:09:52 +03:00
Umer Uddin
6f3a9597f5 simplefb: Introduce ABGR8888
ABGR8888 is a commonly used framebuffer format, and used by p682lpn and vita boards.

Signed-off-by: Umer Uddin <umer.uddin@mentallysanemainliners.org>
2026-05-27 13:09:52 +03:00
Umer Uddin
29cc5c639b simplefb: Fix write order of pixels for FB_FORMAT_BGRA8888
Fixes an issue where pixel data is stored as ABGR, not BGRA

Signed-off-by: Umer Uddin <umer.uddin@mentallysanemainliners.org>
2026-05-27 13:09:52 +03:00
Akari Tsuyukusa
6ded1cbd44 board: Add support for Blackview Tab 15 Pro
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
2026-05-24 10:10:37 +02:00
Akari Tsuyukusa
f41400cbdc lib: simplefb: Add RGB565 format support
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
2026-05-24 10:10:37 +02:00
Akari Tsuyukusa
055ec0fab5 project: Add Clang/LLVM support
Makefile:
Add Clang/LLVM toolchain support

README.md:
Add Clang/LLVM build examples

start.S:
Fix compile error in Clang

```
  AS      arch/aarch64/start.o
/tmp/start-ebf313.s:22:9: error: invalid fixup for movz/movk instruction
 mov x1,_start
        ^
make[1]: *** [scripts/Makefile.build:194: arch/aarch64/start.o] Error 1
```

Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
2026-05-24 10:10:37 +02:00
Aiden Isik
7a2c9a33c9 configs: lucky7: Enable UART 2026-05-22 10:05:37 +02:00
Aiden Isik
6a249a0952 board: lucky7: Add support for UART over USB 2026-05-22 10:05:37 +02:00
Igor Belwon
72226d6b20 board: Add support for Sony Xperia 1 VI (pdx245)
Xperia 1 VI is a flagship phone manufactured by Sony, based on the
Qualcomm Snapdragon 8 Gen 3 Mobile Platform.

Add support for this board.

NOTE: This board is new, and as such, it requires some ugly hax and
a fallback boot method to boot any sort of [u-boot/uniLoader/mainline]
In short:
- build:
  - ARCH=aarch64 CROSS_COMPILE=aarch64-linux-gnu- make -j32
  - cat uniLoader.gz dummy.dtb > uni.dtb
  - mkbootimg --kernel uni.dtb --ramdisk <some ramdisk (required)> \
    --pagesize 4096 --base 0x0 --kernel_offset 0x8000 \
    --ramdisk_offset 0x1000000 --tags_offset 0x100 \
    --dtb_offset 0x1f00000 --header_version 0 --os_version 16.0.0 \
    --os_patch_level 2026-04 -o boot.img
    (yes, all properties are required.)
- prepare device:
 - boot to fastboot mode (volume up and plug in USB)
 - fastboot erase dtbo erase vendor_boot
- flash:
 - fastboot flash boot boot.img continue

Where:
 - dummy.dtb is a skeleton.dtsi with a reserved memory node called
   splash_region as a child of the chosen node.

Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
2026-05-15 00:37:13 +03:00
Igor Belwon
9a497231bb board: Fix a3xelte formatting
We all hate spaces as indentation :/
2026-05-15 00:37:13 +03:00
Igor Belwon
dd06b21b60 soc: Add support for Snapdragon 8 Gen 3 (SM8650/pineapple/lanai) 2026-05-15 00:37:13 +03:00
Aiden Isik
6ae4e8084f main: Pass address of address of DTB to patch_dtb
Pass the address of the address of the DTB to patch_dtb in boot.c, rather than just the address to the DTB.
This allows the modified DTB address to overwrite the address of the original DTB, fixing a bug where
the ramdisk address was not being passed to the kernel via the DTB successfully.
2026-05-14 21:03:32 +02:00
Ivaylo Ivanov
3e61800372 lib: nanoprintf: let the compiler use division instructions for divmod
Due to divmod performing division by subtracting in a linear loop,
it's *really* slow. When performing division with larger numbers (like
32-bit addresses), it goes thru massive amounts of iterations and causes
a stall-like appearance.

Instead, let the compiler handle it by using cpu instructions like
UDIV/MSUB for armv8.

Fixes #86.
2026-05-12 15:33:16 +03:00
Ivaylo Ivanov
732d6f30b9 board: add support for Motorola Edge 30 Fusion
Add basic support for Motorola tundra, usable to boot mainline Linux.
UniLoader has to be packaged with mkbootimg (header_version 3), as it
acts as a wrapper for the kernel image and tree.
2026-05-11 22:04:15 +02:00
Ivaylo Ivanov
24dd909e25 soc: add support for Qualcomm's Snapdragon 888
Define a config option for SM8350 to prepare for supporting devices
with that SoC.
2026-05-11 22:04:15 +02:00
Igor Belwon
84bc0d3d74 board: Add support for the Sony PlayStation Vita
This commit adds support for the PSVita 1xxx/2xxx variants, which have:
 - 4x Cortex A9
 - OLED/LCD display (both types get init. by libbaremetal before)
 - 512MB RAM (ew)
 - Some PowerVR custom GPU (ew)
2026-05-05 00:14:25 +03:00
Igor Belwon
999374b9cc soc: Add support for Sony's Kermit SoC
Used in PlayStation Vita and PlayStation TV platforms

Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
2026-05-05 00:14:25 +03:00
Igor Belwon
93d43c3a82 board: Add support for Lenovo Idea Tab Pro
* Needs to be unlocked via an exploit
* mkbootimg --kernel uniLoader.lz4 --header_version 4 --out boot.img
* Has very slow fastboot (usb 1.1 speeds slow), so flashing via the
  SoC flash mode or fastbootd is recommended
* fastboot flash boot boot.img reboot

Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
2026-05-01 14:30:38 +03:00
Igor Belwon
35a425b5d3 soc: Add support for MediaTek MT6897
Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
2026-05-01 14:30:38 +03:00
faveoled
63319a14bd board: Add support for Realme C35 2026-04-27 14:49:39 +02:00
Spyware_Hunter
c9439e7bba board: Correct codenames for some Samsung devices and minor text changes 2026-04-27 13:00:24 +02:00
Spyware_Hunter
c8c864c1ed configs: Correct codenames for some Samsung devices 2026-04-27 13:00:24 +02:00
Spyware_Hunter
5f4c101b68 README: Correct codenames for some Samsung devices and fix their sorting, add Galaxy A33 5G, delete unnecessary spaces 2026-04-27 13:00:24 +02:00
Igor Belwon
1bd1f6c06a gitmodules: remove
We're not using it anyway
2026-04-21 21:57:25 +03:00
Igor Belwon
f75668571a ci: build_test: Add the build script
Tests all supposed-to-be-working devices (read - has a defconfig)
for compilation errors. No arm devices have defconfigs so it
hardcodes the arm64 compiler for now.
2026-04-21 21:57:25 +03:00
Igor Belwon
9d27cddccf ci: build_test: Adapt to our usecase
- Remove the useless make commands
- Add cross-compilers as dependencies
- Run build_test script
- Bump checkout to v5
2026-04-21 21:57:25 +03:00
Igor Bełwon
0e18fa6c40 ci: build_test: Import template from GitHub Actions 2026-04-21 21:57:25 +03:00
Aiden Isik
9ae8d18028 board: Add support for Samsung Galaxy Watch FE
Adds the initial support for Samsung Galaxy Watch FE (lucky7).
2026-04-21 16:33:50 +02:00
Trijal Saha
84c5f568b3 Makefile: Forcefully regenerate linker.lds
This fixes linking issues with ld.lld when having to regenerate linker.lds after configuration changes.
2026-03-14 15:13:45 +02:00
Igor Belwon
9a03aa6395 arch: Add architecture-dependent kernel copying functions
This is done to clean main/ code of ugly architecture ifdefs.

Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
2026-02-23 23:02:53 +02:00
Igor Belwon
314f2addeb board: fix main.h header 2026-02-23 23:02:53 +02:00
Igor Belwon
eaacd962db main: refactor booting logic
- Move main headers from include/ to include/main/
- Split booting logic to boot.c and boot-fdt.c to avoid cluttering main()
- Conditionally compile boot-fdt only if libfdt is used
- Add some better logging

Change was tested on qemu-virt, which succesfully booted a kernel:
$ qemu-system-aarch64 -machine virt -cpu cortex-a72 -nographic -m 512m -kernel uniLoader.o
[INFO]              .__.____                     .___
[INFO]  __ __  ____ |__|    |    _________     __| _/___________
[INFO] |  |  \/    \|  |    |   /  _ \__  \   / __ |/ __ \_  __\
[INFO] |  |  /   |  \  |    |__(  <_> ) __ \_/ /_/ \  ___/|  |\/
[INFO] |____/|___|  /__|_______ \____(____  /\____ |\___  >__|
[INFO]            \/           \/         \/      \/    \/
[INFO] passed board initialization
[INFO] welcome to uniLoader (e69eba1) - date 2026-02-21 14:01:34 on qemu-virt
[INFO] Booting kernel...
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083]
[    0.000000] Linux version 6.12.73+deb13-arm64 (debian-kernel@lists.debian.org) (aarch64-linux-gnu-gcc-14 (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44) #1 SMP Debian 6.12.73-1 (2026-02-17)
[    0.000000] KASLR enabled
[    0.000000] random: crng init done
[...]

Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
2026-02-23 23:02:53 +02:00
Igor Belwon
ecd7ebf677 virt: disable gzip and libfdt
gzip: qemu shall use uniLoader.o as the kernel which also enables symbol maps and other cool stuff.
so, the gzip-compressed uniLoader image is useless and can slow down the compile process

libfdt: temporary. it doesn't seem to pick up the fdt that is passed when booting raw kernel

Signed-off-by: Igor Belwon <igor.belwon@mentallysanemainliners.org>
2026-02-23 23:02:53 +02:00
tildeguy
e69eba1d89 board: add support for Huawei Mediapad T5
Adds the initial support for Huawei Mediapad T5 (agassi2) and Hi6250-based devices.
2026-02-21 11:16:21 +01:00
tildeguy
88cc20b0d6 project: allow not to load ramdisk but only its size
HiSilicon bootloader copies the ramdisk itself, and marks
its memory region as protected, so we can't memcpy on it.
Even more: we also can NOT include the ramdisk into uniLoader
for it, because the kernel partition is too small.

The easiest workaround for that is just using an empty
blob/ramdisk, so it won't be copied. But it breaks
libfdt, as it doesn't know the actual ramdisk size.
2026-02-21 11:16:21 +01:00
tildeguy
4c41a44b62 lib: simplefb: allow boards to override font scale
Make it possible to set font scale via video_info struct,
as a dynamic font scale may be slightly too big on some screens.
2026-02-21 11:16:21 +01:00
faveoled
c4d3f6490e board: add support for Samsung Galaxy S10 2026-02-07 09:34:05 +02:00
Hendra Manudinata
da2cd8d222 configs: j4lte: Add required addresses 2026-01-27 10:52:40 +02:00
R0rt1z2
741f3e6a61 arch: zero BSS section during early boot
The C runtime requires that uninitialized global variables are zero.
In a bare-metal environment, memory contents are undefined at startup
and the BSS section is not automatically cleared, so we must zero out
this entire section ourselves.

Without this, static variables contain garbage values, leading to
unpredictable behavior. For example, the simplefb driver uses a static
variable to track the current print position, which resulted in text
being drawn at random locations on the screen.
2026-01-13 14:06:09 +02:00