Skip to content

Commit 881a53b

Browse files
Make gpu initialization optional
GPU stuff now requires rust, make it optional Signed-off-by: Sasha Finkelstein <[email protected]>
1 parent 7d8b329 commit 881a53b

2 files changed

Lines changed: 50 additions & 4 deletions

File tree

Makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,25 @@ ifeq ($(RELEASE),1)
6464
CFG += RELEASE
6565
endif
6666

67+
WANT_RUST := 0
68+
ifeq ($(CHAINLOADING),1)
69+
CFG += CHAINLOADING
70+
WANT_RUST := 1
71+
endif
72+
ifneq ($(NO_GPU_INIT),1)
73+
WANT_RUST := 1
74+
GPU_OBJECTS := kboot_gpu.o
75+
CFG += DO_GPU_INIT
76+
else
77+
GPU_OBJECTS :=
78+
endif
79+
6780
# Required for no_std + alloc for now
6881
export RUSTC_BOOTSTRAP=1
82+
ifeq ($(WANT_RUST),1)
6983
RUST_LIB := librust.a
70-
ifeq ($(CHAINLOADING),1)
71-
CFG += CHAINLOADING
84+
else
85+
RUST_LIB :=
7286
endif
7387

7488
LDFLAGS := -EL -maarch64elf --no-undefined -X -Bsymbolic \
@@ -163,7 +177,7 @@ OBJECTS := \
163177
$(MINILZLIB_OBJECTS) $(TINF_OBJECTS) $(DLMALLOC_OBJECTS) $(LIBFDT_OBJECTS) $(RUST_LIB)
164178

165179
FP_OBJECTS := \
166-
kboot_gpu.o \
180+
$(GPU_OBJECTS) \
167181
math/expf.o \
168182
math/exp2f_data.o \
169183
math/powf.o \

src/kboot.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-License-Identifier: MIT */
22

3+
#include "../build/build_cfg.h"
4+
35
#include <stdint.h>
46

57
#include "kboot.h"
@@ -47,7 +49,33 @@ static char *chosen_params[MAX_CHOSEN_PARAMS][2];
4749

4850
extern const char *const m1n1_version;
4951

52+
#ifdef DO_GPU_INIT
5053
int dt_set_gpu(void *dt);
54+
#else
55+
static int dt_set_gpu(void *dt)
56+
{
57+
int gpu, node;
58+
59+
gpu = fdt_path_offset(dt, "gpu");
60+
if (gpu >= 0)
61+
fdt_setprop_string(dt, gpu, "status", "disabled");
62+
63+
node = fdt_path_offset(dt, "/reserved-memory/uat-handoff");
64+
if (node >= 0)
65+
fdt_setprop_string(dt, node, "status", "disabled");
66+
67+
node = fdt_path_offset(dt, "/reserved-memory/uat-pagetables");
68+
if (node >= 0)
69+
fdt_setprop_string(dt, node, "status", "disabled");
70+
71+
node = fdt_path_offset(dt, "/reserved-memory/uat-ttbs");
72+
if (node >= 0)
73+
fdt_setprop_string(dt, node, "status", "disabled");
74+
75+
printf("m1n1 was built without rust support, GPU will not be initialized\n");
76+
return 0;
77+
}
78+
#endif
5179

5280
#define DT_ALIGN 16384
5381

@@ -2332,7 +2360,11 @@ static int dt_disable_missing_devs(const char *adt_prefix, const char *dt_prefix
23322360
return ret;
23332361
}
23342362

2335-
static int dt_transfer_virtios(void)
2363+
#ifdef RELEASE
2364+
__attribute__((unused))
2365+
#endif
2366+
static int
2367+
dt_transfer_virtios(void)
23362368
{
23372369
int path[3];
23382370
path[0] = adt_path_offset(adt, "/arm-io/");

0 commit comments

Comments
 (0)