A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1#!/usr/bin/perl
2
3# Calculate the highest possible location for an overlay based
4# on a reference map file (.refmap)
5
6sub map_scan {
7 # The buflib handle table is a few hundred bytes, just before
8 # the plugin buffer. We assume it's never more than 1024 bytes.
9 # If this assumption is wrong, overlay loading will fail.
10 my $max_handle_table_size = 1024;
11 my ($map) = @_;
12 my $ramstart = -1, $ramsize = -1, $startaddr = -1, $endaddr = -1;
13 open (MAP, "<$map");
14 while (<MAP>) {
15 if ($_ =~ /^PLUGIN_RAM +0x([0-9a-f]+) +0x([0-9a-f]+)$/) {
16 $ramstart = hex($1);
17 $ramsize = hex($2);
18 }
19 elsif ($_ =~ / +0x([0-9a-f]+) +_?plugin_start_addr = ./) {
20 $startaddr = hex($1);
21 }
22 elsif ($_ =~ / +0x([0-9a-f]+) +_?plugin_load_end_addr = ./) {
23 $endaddr = hex($1);
24 }
25 }
26 close (MAP);
27 if ($ramstart < 0 || $ramsize < 0 || $startaddr < 0 || $endaddr < 0
28 || $ramstart != $startaddr) {
29 printf "Could not analyze map file.\n";
30 exit 1;
31 }
32 return $ramstart + $ramsize - $endaddr - $max_handle_table_size;
33}
34
35printf map_scan($ARGV[0]) & ~0xf;