Skip to content

Commit

Permalink
Add support for booting on t8012 (T2)
Browse files Browse the repository at this point in the history
Address some peculiarities specific to T2:

- Reserved memory at top is very large, either 512 MB or 1536 MB, and only
lowest 512 MB is for OS use.

- Some ranges in /arm-io/ranges is not aligned to the page size. We align
them ourselves instead.

- On models with a screen, the framebuffer is extremely narrow at 60 pixels
in width, so add a smaller logo.

Signed-off-by: Nick Chan <towinchenmi@gmail.com>
  • Loading branch information
asdfugil committed Feb 3, 2025
1 parent a300ecc commit 0bc4955
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ OBJECTS := \
afk.o \
aic.o \
asc.o \
bootlogo_128.o bootlogo_256.o \
bootlogo_48.o bootlogo_128.o bootlogo_256.o \
chainload.o \
chainload_asm.o \
chickens.o \
Expand Down
Binary file added data/bootlogo_48.bin
Binary file not shown.
Binary file added data/bootlogo_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/makelogo.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env sh
convert bootlogo_48.png -background black -flatten -depth 8 rgba:bootlogo_48.bin
convert bootlogo_128.png -background black -flatten -depth 8 rgba:bootlogo_128.bin
convert bootlogo_256.png -background black -flatten -depth 8 rgba:bootlogo_256.bin
15 changes: 14 additions & 1 deletion src/fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@ static struct {
bool active;
} console;

extern u8 _binary_build_bootlogo_48_bin_start[];
extern u8 _binary_build_bootlogo_128_bin_start[];
extern u8 _binary_build_bootlogo_256_bin_start[];

extern u8 _binary_build_font_bin_start[];
extern u8 _binary_build_font_retina_bin_start[];

const struct image logo_48 = {
.ptr = (void *)_binary_build_bootlogo_48_bin_start,
.width = 48,
.height = 48,
};

const struct image logo_128 = {
.ptr = (void *)_binary_build_bootlogo_128_bin_start,
.width = 128,
Expand Down Expand Up @@ -409,7 +416,13 @@ void fb_init(bool clear)
fb.ptr = malloc(fb.size);
memcpy(fb.ptr, fb.hwptr, fb.size);

if (cur_boot_args.video.depth & FB_DEPTH_FLAG_RETINA) {
// This is the touchbar, make everything tiny
if (chip_id == T8012) {
logo = &logo_48;
console.font.ptr = _binary_build_font_bin_start;
console.font.width = 8;
console.font.height = 16;
} else if (cur_boot_args.video.depth & FB_DEPTH_FLAG_RETINA) {
logo = &logo_256;
console.font.ptr = _binary_build_font_retina_bin_start;
console.font.width = 16;
Expand Down
5 changes: 4 additions & 1 deletion src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,11 @@ static void mmu_map_mmio(void)
u64 bus = ranges[2] | ((u64)ranges[3] << 32);
u64 size = ranges[4] | ((u64)ranges[5] << 32);

mmu_add_mapping(bus, bus, size, MAIR_IDX_DEVICE_nGnRnE, PERM_RW_EL0);
/* T2 is really stupid */
if (chip_id == T8012)
size = ALIGN_UP(size, PAGE_SIZE);

mmu_add_mapping(bus, bus, size, MAIR_IDX_DEVICE_nGnRnE, PERM_RW_EL0);
ranges += 6;
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,23 @@ void dump_boot_args(struct boot_args *ba)
break;
}
if (!mem_size_actual) {
mem_size_actual = ALIGN_UP(ba->phys_base + ba->mem_size - 0x800000000, BIT(30));
if (chip_id == T8012) {
int anode = adt_path_offset(adt, "/arm-io/mcc");

/*
* Lower 512 MB intented for OS use, upper 512 or 1536 MB is some sort
* of SSD cache. Cannot use dram-size, it may not exist in older firmwares
* This property is changed from 4 to 2 by iBoot on 1 GB RAM models.
*/

u32 dcs_num_channels = 0;
if (anode > 0 && ADT_GETPROP(adt, anode, "dcs_num_channels", &dcs_num_channels) > 0)
mem_size_actual = dcs_num_channels * 0x20000000;
else
mem_size_actual = 0x40000000;
} else {
mem_size_actual = ALIGN_UP(ba->phys_base + ba->mem_size - 0x800000000, BIT(30));
}
printf("Correcting mem_size_actual to 0x%lx\n", mem_size_actual);
}
}
Expand Down

0 comments on commit 0bc4955

Please # to comment.